FileUpload img = (FileUpload)UploadImg;
Byte[] imgByte = null;
if (img.HasFile && img.PostedFile!=null)
{
HttpPostedFile File = UploadImg.PostedFile;
imgByte = new Byte[File.ContentLength];
File.InputStream.Read(imgByte, 0, File.ContentLength);
} **strong text**
here i want to save an image in database . so i want to convert an image to byte array. for that i wrote the above code. but here the if condition is not executed
Assuming you have a file upload control on your page:
the following should work: