title: Downloading zipfile causes file corruption
body: <p>I tried to download a zipfile from a webserver programatically using javascript- and am facing challenges with the archive getting corrupted. </p>
  
  <p>I am using the following function to download</p>
  
  <pre><code>function download(){
          var http = new XMLHttpRequest();
          http.open("GET", 'http://jadonchemicals.com/sample.zip');
          http.setRequestHeader("dataType", "jsonp");
          http.onreadystatechange = function () {
               if (http.readyState == 4 &amp;&amp; http.status == 200) 
               {
                var blobdata=new Blob([http.responseText], {type:  "application/zip"});
               var a = document.createElement("a");
               a.href = window.URL.createObjectURL(blobdata);
               a.click();
               }
           };
              http.send();
  }
  </code></pre>
  
  <p>I get the following errors when I try to open the archive</p>
  
  <pre><code>a) The file header is corrupt
  b) unexpected end of archive
  </code></pre>
  
  <p>As an example, while downloading the sample.zip file on this link, the file does get downloaded to a size of 975k.
  <a href="http://jadonchemicals.com/Blobtozip/" rel="nofollow noreferrer">http://jadonchemicals.com/Blobtozip/</a></p>
  
  <p>When I try to do the same programatically using javascript by linking the script to a button, the file size increases to 1779k and the file is corrupted</p>
  
  <p>I suspect this is a result of an encoding issue. Could you suggest what I should do to resolve?</p>