title: Upload file from url via javascript
body: <p>I have the following problem:</p>
  
  <p>I have a web page that show 2 images, when user selects one of these pictures, a javascript function must take this picture and send it to another server (with standard multipart post)</p>
  
  <p>I have only url of image, so first I download it via javascript, then I try to send it to server, follow my code</p>
  
  <pre><code>function sendImgFromUrl(url){
      var xhr = new XMLHttpRequest();
      xhr.open('GET', url, true);
      xhr.responseType = 'blob';
      xhr.onload = function(e) {
          if (this.status == 200) {
              var reader = new FileReader();
              reader.onloadend = function(){
                  var file = event.target.result;
  
                  var resReq = new FormData();
                  resReq.append("service_name",service_name);
                  resReq.append("file",file); 
  
                  $.ajax({
                      url: "myurl", 
                      data: resReq,
                      type: 'POST',
                      processData: false, 
                      contentType: false, 
                      async: false,
                      complete : function(response){
                           console.log(response);
                      }
  
                   }); 
              }
              reader.readAsBinaryString(this.response);
  
          }
      };
      xhr.send();
  }
  </code></pre>
  
  <p>What I obtain is a call with an Object instead of (image)File</p>
  
  <pre><code>-----------------------------201521280032720 
  Content-Disposition: form-data;      
  name="file" [object FileReader] 
  -----------------------------201521280032720
  </code></pre>