Answers for "upload image and preview using js source code"

9

preview image file upload javascript

<input type="file" accept="image/*" onchange="loadFile(event)">
<img id="output"/>
<script>
  var loadFile = function(event) {
    var output = document.getElementById('output');
    output.src = URL.createObjectURL(event.target.files[0]);
    output.onload = function() {
      URL.revokeObjectURL(output.src) // free memory
    }
  };
</script>
Posted by: Guest on November-09-2020

Code answers related to "upload image and preview using js source code"

Code answers related to "Javascript"

Browse Popular Code Answers by Language