Friday, May 17, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
87
rated 0 times [  88] [ 1]  / answers: 1 / hits: 27904  / 12 Years ago, mon, october 15, 2012, 12:00:00

I am sending base64 encoded image from client side using javascript (I am creating Screenshot uploader applet for asp.net application using http://supa.sourceforge.net/) and this sends an ajax request to server to store the image. At server I am using HttpContext in GenericHanlder in asp.net application.



How to convert image data from HttpContext to image at server?


More From » c#

 Answers
25

First, you need to convert the base 64 back into bytes:



byte[] data = System.Convert.FromBase64String(fromBase64);


Then, you can load it into an instance of Image:



MemoryStream ms = new MemoryStream(data);
Image img = Image.FromStream(ms);


If you want to save it to a file instead, use System.IO.File.WriteAllBytes


[#82537] Sunday, October 14, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackie

Total Points: 442
Total Questions: 107
Total Answers: 94

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
jackie questions
Sat, Sep 18, 21, 00:00, 3 Years ago
Wed, Jul 14, 21, 00:00, 3 Years ago
;