I have posted a form with an image. And receiving that in my controller
var image=Request.Files["hiddenUploadButton"];
Now I want to convert my image to Stream. How to do that?
I have posted a form with an image. And receiving that in my controller
var image=Request.Files["hiddenUploadButton"];
Now I want to convert my image to Stream. How to do that?
var stream = Request.Files["hiddenUploadButton"].InputStream;
Please see this link.
Perhaps you want to do something like this?
if you want to save file try following code snippet
HttpPostedFile file = Request.Files["myFile"];
//check file was submitted
if (file != null && file.ContentLength > 0)
{
string fname = Path.GetFileName(file.FileName);
file.SaveAs(Server.MapPath(Path.Combine("~/App_Data/", fname)));
}
How TO Convert to stream,
HttpPostedFile file = Request.Files["myFile"];
var FileLen = file .ContentLength;
byte[] input = new byte[FileLen];
System.IO.Stream MyStream;
// Initialize the stream.
MyStream = file .InputStream;
// Read the file into the byte array.
MyStream.Read(input, 0, FileLen);