title: Passing an image from JavaScript to C# in an ASP.NET app?
body: <p>I have an Image variable loaded in a <code>JavaScript</code> app, and I want to pass it to a <code>C#</code> method in my <code>ASP.NET</code> app (so I can store it in a database).  The only problem I am having is getting the image's data itself to the <code>C#</code> method.  I tried using an <code>AJAX</code> call (it's a <code>GET</code>) with the <code>C#</code>'s method's <code>byte[]</code> parameter set to the Image's .Picture, but the <code>byte[]</code> is empty.</p>
  
  <p>How do I get the image's data from the JavaScript script to the C# method?</p>
  
  <p><strong>UPDATE:</strong>
  I tried copying the image to a canvas using drawImage on the canvas's rendering context, but the image has to come from my local computer, so when I subsequently try to call canvas.toDataURL, it throws a DOM Security error.</p>
  
  <p>I also considered using FileReader to get the data directly rather than loading it as an image, but, for political reasons, I have to support browsers that don't implement FileReader yet.</p>
  
  <p>Am I asking for something that just isn't possible in JavaScript?  (There must be a way of doing this (not necessarily in JS), as Facebook implements loading images from the client computer's local file system.)</p>