Rank: Newbie
Groups: Member
Joined: 7/27/2009(UTC) Posts: 1
|
Hi, I want the save the uploaded files directly into database in byte format without saving the file anywhere else. I want to convert the uploaded file into System.IO.FileStream in C#. How is it possible to convert the uploaded file into Stream or bytes ?
|
|
|
|
Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Quote:I want the save the uploaded files directly into database in byte format without saving the file anywhere else. I want to convert the uploaded file into System.IO.FileStream in C#. How is it possible to convert the uploaded file into Stream or bytes ? I am sorry for delay. In you use Image Uploader without ASP.NET control, then System.Web.HttpPostedFile.InputStream is what you need: (code is untested) Code:HttpPostedFile sourcefile = Request.Files["SourceFile_1"];
Byte[] data = new Byte[sourceFile.ContentLength]
sourceFile.InputStream.Read(data, 0, sourceFile.ContentLength);
If you use Image Uploader ASP.NET control, then you should use the following code: (code is untested) Code: private void ImageUploader1_FileUploaded(object sender, FileUploadEventArgs e)
{
Byte[] data = new Byte[e.SourceFile.ContentLength]
e.SourceFile.InputStream.Read(data, 0, e.SourceFile.ContentLength);
}
|
Best regards, Fedor Skvortsov
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.