title: How to convert img src into picture using ajax and C#
body: <p>i have my html, but i'm so confused how can i convert an image source to picture, i made some code below, but i didn't why it is not able to convert the string(img src) to byte, help me, </p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;img src="data:image/jpeg;base64, ...&gt;
  </code></pre>
  
  <p><strong>JQUERY</strong></p>
  
  <pre><code>var getimg = parentDiv.find("img");\
  var pic = getimg.attr('src');
  var filebase = pic.split(";");
  filebase[1] = filebase[1].replace("base64,", "");
  console.log(filebase[1]);
  var realname  = "picsample.jpg"
  console.log(pic);
  $.ajax({
     url: '/FileBrowser/UploadImage',
     type: 'POST',
     datatype: 'json',
     data: { file: filebase[1], filename:realname},
     cache: false,
     beforeSend: function() {
  
     },
     success: function(result) {
         console.log(result);
     },
     complete: function() {
  
     },
     error: function(error) {
  
     }
  });
  </code></pre>
  
  <p><strong>[HttpPost]</strong></p>
  
  <pre><code>public string UploadImage(string file, string filename){
      string filepath = Path.Combine(Server.MapPath("~/Media"), filename);
  
      using (FileStream fs = new FileStream(filepath, FileMode.Create)){
  
          using (BinaryWriter bw = new BinaryWriter(fs)){
  
              byte[] data = Convert.FromBase64String(file);
              bw.Write(data);
              bw.Close();
          }
  
      }
      return "Data";
  }
  </code></pre>