Friday, March 23, 2012

FileUpload

I have gotten FileUpload in VB.Net to work fine in saving a file to a web server folder but cannot find some examples on how to save the file as an image on sql200. Can anyone point me in the write direction - thanks.

Please refer to this article, which contains a sample about how to deal with BLOB data in SQL Server:
http://forums.asp.net/thread/1254026.aspx

|||

i dont like it, but i figured it out and have written about in my blog

http://weblogs.asp.net/hpreishuber/archive/2006/02/17/438498.aspx

|||

string fileName = FileUpload1.PostedFile.FileName;

byte[] lc_ByteFile = new byte[FileUpload1.FileContent.Length];

lc_ByteFile = ReadFileToByteArray(fileName, FileUpload1.FileContent.Length);

if (FileUpload1.FileName.EndsWith(".jpg") || FileUpload1.FileName.EndsWith(".jpeg") || FileUpload1.FileName.EndsWith(".gif") || FileUpload1.FileName.EndsWith(".bmp"))

{

System.Drawing.Image newImage;

MemoryStream stream = new MemoryStream(lc_ByteFile);

newImage = System.Drawing.Image.FromStream(stream);

newImage.Save("D:\\NewImage.bmp");

}

Try this out it works

No comments:

Post a Comment