Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Forum
how to upload default image into database when no image file is selected from fileupload control in
May 08, 2013
i have to insert default image into databse..when no image is selected from fileupload control..
here is code...not working for default image...
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 Date: May 14, 2013 Points: 20
I guess its bad idea to upload default image when user has not selected any..its better to check if the image column is null in client side show default image..with this approach you can save Database space too.
Posted Date: March 30, 2014 Points: 20
Just do a google search and find you guys are talking about the same issue. So find the solution from following links.
Posted Date: July 13, 2014 Points: 20
you can use the below code
Byte imgByte = null;
if (FileUpload1.HasFile && FileUpload1.PostedFile.ContentLength < 1055799)
HttpPostedFile File = FileUpload1.PostedFile;
imgByte = new Byte[File.ContentLength];
File.InputStream.Read(imgByte, 0, File.ContentLength);
FileInfo _fileInfo = new FileInfo(Server.MapPath("~") + "\\App_Folder\\Content\\AboutUs\\Images\\Logo.jpg");
FileStream _fileStream = new FileStream(_fileInfo.FullName, FileMode.Open);
imgByte = new Byte[_fileStream.Length];
_fileStream.Read(imgByte, 0, Convert.ToInt32(_fileStream.Length));
send "imgByte" in insertcommend
For more visit
To post reply
Related Questions Related Questions
upload image file in windows application
image is not displaying in image control after selecting file from fileuploader control in c#asp.net
how to insert image from selected image in IMAGE CONTROL in asp.net
Image store in Database SQL SERVER
How to insert data of selected checkboxlist control in database.. (sql server)
Image display in image control
How can I display a picture in an Image Control?
how to show image in imagebox/picturebox on selection of image file from fileuploader
how to retreive and show image in image control in asp.net,c#
Save image in XML file
Latest Forum Questions From The Same Category
Slash(/) in Combobox
attaching the report in the web page
How do i get payment status in redirect page using bitpay?
Login with Facebook and Save details in database
Login with facebook account in my website
How to make a nested datalist control?
What class does Icon derive from?
What are the validation controls?
What''s the difference between an interface and abstract class?
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more
Quick Links For Forum Categories:
Hall of Fame
Terms of Service
Tell A Friend