How to create an image on the fly and display it on the webpage without saving it on server

Posted by Qazitanzeel under ASP.NET on 1/11/2012 | Points: 10 | Views : 1315 | Status : [Member] | Replies : 2
Respected

I am developing a module in asp.net. Where a user submits a picture using fileupload control to the server. At server i Have to create image of the uploaded file without saving it on server and show it on the webpage in response.
Stream fi = FileUpload1.PostedFile.InputStream;
var ext = FileUpload1.PostedFile.ContentType;
var imageOrNot = ext.Contains("image") ? true : false;

if (imageOrNot)
{
byte[] imagearr = new byte[fi.Length];
fi.Read(imagearr, 0, (int)fi.Length);
fi.Close();
Response.Write(imagearr);
MemoryStream ms = new System.IO.MemoryStream(imagearr);
System.Drawing.Image imgTemp = System.Drawing.Image.FromStream(ms);

To Some Extent I have coded some of the portion but the major portion is to be done




Responses

Posted by: Webmaster on: 1/11/2012 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Thanks for asking this question.

I am assuming you want to create an image based on another image already existing, you can read this article to solve your problem

http://www.dotnetfunda.com/articles/article63.aspx

Thanks

Best regards,
Webmaster
http://www.dotnetfunda.com

Qazitanzeel, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Qazitanzeel on: 1/11/2012 [Member] Starter | Points: 25

Up
0
Down
Your reply help me a lot, but i need such a code that without saving the posted file on the server i can create

image object of that posted image and then display back to the webpage

Qazitanzeel, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response