get remote image into string
<p>The question says it all: how to get a remotely hosted image into a string. I will later use <code>XMLHTTPPost</code> to upload the content. This is <code>javascript</code> question, for those who don't read tag line.</p>

<p>@Madmartigan: the script itself is executed in rather odd manner: user uses <code>javascript:</code> to append the script from the remove host. (this gives access to the user cookie session, which we need in order to proceed) This generates form, giving user ability to setup some texts. (this is easy bit) When user clicks <code>upload</code> the script must get an image hosted on remote host. I am trying to get the image from the remote host as a string and then use something like the function below to convert it to binary. So, how do I do that?</p>

<pre><code>function toBin(str){
 var st,i,j,d;
 var arr = [];
 var len = str.length;
 for (i = 1; i&lt;=len; i++){
                //reverse so its like a stack
  d = str.charCodeAt(len-i);
  for (j = 0; j &lt; 8; j++) {
   st = d%2 == '0' ? "class='zero'" : "" 
   arr.push(d%2);
   d = Math.floor(d/2);
  }
 }
        //reverse all bits again.
 return arr.reverse().join("");
}
</code></pre>

<p>I should mention, that I managed to find things like:</p>

<pre><code>var reader = new FileReader();
reader.onload = function() {
  previewImage.src = reader.result;
}
reader.readAsDataURL(myFile);
</code></pre>

<p>However, they are very browser dependent and therefore not very useful.</p>

<p>I am trying to avoid using base64 because of the redundant size increase.</p>
