i want to have a browse button that allows me to select an image.
I was also given this code to use it
byte[] file_Link = null;
if (fileLink.FileName != null && fileLink.FileName !="")
{
System.IO.FileInfo file = new System.IO.FileInfo(fileLink.PostedFile.FileName);
attachmentExtension = file.Extension.Remove(0, 1).ToUpper();
file_Link = new byte[fileLink.PostedFile.ContentLength];
HttpPostedFile uploadedImage = fileLink.PostedFile;
uploadedImage.InputStream.Read(file_Link, 0, (int)fileLink.PostedFile.ContentLength);
}
what does this code mean and how is that helpful?
It loads the file you've uploaded into memory (as an array of bytes). It doesn't help you a great deal to be honest. If you included some code to save the file, or to write the file to the response then it might be of some use. It depends what you mean
by "browse for an image".
i have a fileupload i want to browse for an image and save it in the database in the form of byte.
is the above code enough or i still need to write any addition code
You just need the bit of code to save the byte array to the database. Google for "saving uploaded images to sql server" and you should find lots of complete examples.
lolo512
i have a fileupload i want to browse for an image and save it in the database in the form of byte.
is the above code enough or i still need to write any addition code
Check the below links which has details explanation with source code
沒有留言:
張貼留言