how to upload default image into database when no image file is selected from fileupload control in

Posted by Parthibansk under ASP.NET on 5/8/2013 | Points: 10 | Views : 1281 | Status : [Member] | Replies : 1
i have to insert default image into databse..when no image is selected from fileupload control..

here is code...not working for default image...

if (FileUpload1.HasFile)
string FileName = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(Server.MapPath("~/UPLOADEDFILES/" + FileName));
feedBack.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, FileName));

string filename="~/images/"+ "sun.gif";
filename.pPropertyImage = filename;



Posted by: Kmandapalli on: 5/9/2013 [Member] Silver | Points: 25


Whenever you are uploading an Image, then that Image will get saved into Upload folder.
Initially, the Upload folder will be empty because you did not select any Image.

so, to get a default Image when the user does not select any Image is to save an Image initially into the Upload folder.
When there is no file, You can just retreive that default Image....

Mark as Answer if satisfied.......

Shree M

Kavya Shree Mandapalli

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response