google

Converting a base64 string into the jpg or png Image and save in a folder in website

| Wednesday, March 4, 2015
Converting a base64 string into the jpg or png Image and save in a folder in website.

This feature can be used for saving the images from the Mobile apps.



  if (!string.IsNullOrEmpty(base64Image))  
     {  
       using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(base64Image)))  
       {  
         using (Bitmap bm2 = new Bitmap(ms))  
         {  
           bm2.Save(HostingEnvironment.MapPath("~/upload/" + "Pic" + ".jpg"));  
         }  
       }  
     }  


The above code has been implemented in a .Net based WCF web service method for saving the image from the mobile app which is returning image as base64 string when uploaded from the mobile.

0 comments:

Post a Comment

Next Prev
▲Top▲