Save jpg on project folder instead of show to user

Last Reply on May 30, 2016 10:07 AM By Shashikant

Posted on May 30, 2016 09:49 AM

Hi,

 

I have this code which is export div data to png its working fine.

I want when click on button div export to png and save it on project folder as image and user just receive message that image save successfully.

 

 

Posted on May 30, 2016 09:58 AM Modified on on May 30, 2016 10:06 AM

Hi,

Please refer below code

C#

string base64 = Request.Form[hfImageData.UniqueID].Split(',')[1];
byte[] bytes = Convert.FromBase64String(base64);
File.WriteAllBytes(Server.MapPath("~/MyImage/ImageName.jpg"),bytes);

VB

Dim base64 As String = Request.Form(hfImageData.UniqueID).Split(","C)(1)
Dim bytes As Byte() = Convert.FromBase64String(base64)
File.WriteAllBytes(Server.MapPath("~/MyImage/ImageName.jpg"), bytes)

I hope this will help you out.