Sep 14, 2010 01:44 PM|amorphisciol|LINK
Got a problem with regards to the file upload control on database updates. The problem is in my CMS, when a user tries to update content for a page it will add null to the fields containing the image path. What I need is for the system to check if the uploader
has no image and if hasn't it has to do nothing. It can't add empty strings or null values as this will remove the original image path. Although they still need to be able to do image updates if the uploader has a file(this bits not a problem).
Heres a snipet of code to demonstrate what I'm trying to achieve.
protected void Button1_Click(object sender, EventArgs e)
AddMenu menu = new AddMenu();
string APP_PATH = Server.MapPath(Common.GetAppSetting("_MENU_PATH"));
if (FileUpload1.HasFile == false)
menu.Menu_Image1 = /////// Its this bit that has to do nothing
//// Menu_Image1 calls a Parameter on the data layer
/// Ie cmd.Parameters.AddwithValue("@image", _menu_image1)
else if (FileUpload1.HasFile)
if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.ContentLength > 0)
Uploader upload1 = new Uploader(FileUpload1);
upload1.MaxSize = 2097152;
upload1.Resize = true;
if (upload1.UploadImageFile(APP_PATH, FileUpload1.FileName))
menu.Menu_Image1 = path + upload1.FileName;
Would be grateful for any advice. Thanks in advance.