Click here to Skip to main content
16,012,153 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created re sized image from image which lies in folder of my web application. temporary i have stored this images into another image folder of my application. But i don't want to store that image into folder. I want to post that image and image name directly to another webpage of different application.

how to do that?

It would be great if some one provides me with solution code on current page from which re sized image needs to post and target page code...

Thanks in advance..
Posted

1 solution

You can always do it on the fly. Resize the image using System.Drawing.Bitmap class and save the resized instance directly to the using the class System.Web.HttpResponse:
http://msdn.microsoft.com/en-us/library/system.web.httpresponse%28v=vs.110%29.aspx[^].

Look at the simple code sample shown on this MSDN page. It created the bitmap, draws some bimap on the fly and sends it in HTTP response via the Bitmap.Save method. You can do almost the same. Only you need to open original bitmap, create a new bitmap and draw the original bitmap on the new bitmap scaling it to the target size using appropriate System.Drawing.Graphics.DrawImage method:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawimage.aspx[^].

—SA
 
Share this answer
 
Comments
Member 9884645 6-Mar-13 7:41am    
Thanks for your reply..

I have resized the image but i dont know how to post it now.. and how i will receive it on target page.... so could you provide coding for both pages.... post page and receiving page as well...

Please help me..
Sergey Alexandrovich Kryukov 6-Mar-13 11:25am    
I already explained it. Which part is not clear?
—SA
Sergey Alexandrovich Kryukov 6-Mar-13 11:31am    
Please see the code sample in the page I referenced and add reading and drawing a bitmap on a bitmap. Your code below is wrong...
—SA
Member 9884645 6-Mar-13 7:44am    
I write code to post Image on source page as below...I am not sure about it.. If it is correct code then how to receive image on target page ???? Here folder contains the path of the file in which it lies and Fname is name of the image file.

ASCIIEncoding encoding = new ASCIIEncoding();
string postImg = folder + Fname;
byte[] data = encoding.GetBytes(postImg);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost:51399/TestReceive.aspx");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();

newStream.Write(data, 0, data.Length);
newStream.Close();
Sergey Alexandrovich Kryukov 6-Mar-13 11:26am    
This is the request part. Now, where is your write part?
Look, can you see a difference between request and response. Why to you post anything?!
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900