Answers for "filereader javascript example"

1

filereader javascript example

//HTML
<input type='file' accept='image/*' onchange='openFile(event)'><br>
<img id='output'>

//Javascript
var openFile = function(event) {
  var input = event.target;

  var reader = new FileReader();
  reader.onload = function(){
    var dataURL = reader.result;
    var output = document.getElementById('output');
    output.src = dataURL;
  };
  reader.readAsDataURL(input.files[0]);
}
Posted by: Guest on May-22-2020
1

use filereader javascript

function displayImage(e) {
        if (e.files[0]) {
            var reader = new FileReader();
            reader.onload = function(e) {
                document.querySelector('#profileDisplay').setAttribute('src', e.target.result);
            }
            reader.readAsDataURL(e.files[0]);
        }
    }
Posted by: Guest on September-08-2021

Code answers related to "filereader javascript example"

Code answers related to "Javascript"

Browse Popular Code Answers by Language