Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

js download File object

<input type="file" id="uploader"/>
<script>
  // Download an image from a File() Object:
  uploader.addEventListener("change", e =>{
    const file = e.target.files[0];
    const blob = new Blob( [file], { type: file.type } );
    const elem = window.document.createElement('a');
          elem.href  = window.URL.createObjectURL(blob);
          elem.download = file.name;        
    document.body.appendChild(elem);
    elem.click();        
    document.body.removeChild(elem);
  })
</script>
 
PREVIOUS NEXT
Tagged: #js #download #File #object
ADD COMMENT
Topic
Name
6+8 =