0

I am trying to upload image and want to save in folder. For this I am doing

I am using image data url of uploaded image and passing it through ajax via form to .ashx page (asp.net c#). I have succesfully uploaded image and send to .ashx page. But on ashx page I am unable to extract image and save it.

My Ajax Code that send Image as image dataurl to ashx page.

var mgsrc = document.getElementById('result_image').value;
var fd = new FormData();    
   fd.append('image', mgsrc );
    $.ajax({
          url: 'http://localhost:53582/Hulk%20Man%20Vers/Handler.ashx',
          data: fd,
          processData: false,
          contentType: false,
          type: 'POST',
          success: function(data){
            alert(data);
          }
        });

   }

.ashx page Code that Receive form.

public void ProcessRequest (HttpContext context) 
    {
        string e = context.Request.Form.ToString();
        var imageBase64String = context.Request.Form["image"];
        byte[] encodedBytes = Encoding.UTF8.GetBytes(imageBase64String);

//now what to write to get image and save it in folder
     }

Somebody , Please let me know how I can save the image. I will be very greatefull . Trying the code from last 5 days.

user3119503
  • 53
  • 2
  • 9
  • http://stackoverflow.com/questions/381508/can-a-byte-array-be-written-to-a-file-in-c – lothlarias Dec 19 '13 at 14:32
  • I am getting data inside form , not in file. Data indide form is in this format image=data%3aimage%2fjpeg%3bbase64%2c%2f9j%2f4AAQSkZJRgABAQ.............. – user3119503 Dec 19 '13 at 14:37
  • http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery ... does not work with IE however! – BenjaminPaul Dec 19 '13 at 14:41
  • I have completed the client side code, everything is working fine. But I am stuck with Server side code, where I have to save image in folder. Your Refereed link explains about posting data , but how to get that posted data in .net c# and save it. – user3119503 Dec 19 '13 at 14:52

0 Answers0