Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <input id="file" type="file">
</body>
</html>
 
var fileInput = document.getElementById('file');
fileInput.addEventListener('change', function(e) {
  var reader = new FileReader(); //create reader
  reader.onload = function() { //attach onload
    //do something with the result
    console.log(reader.result);
    localStorage.img = reader.result; //saved to localStorage
    createImg(localStorage.img); //retrieved from localStorage
  };
  var file = e.target.files[0];
  reader.readAsDataURL(file); //trigger onload function
});
function createImg(dataUri) {
  var img = document.createElement('img');
  img.src = dataUri;
  document.body.appendChild(img);
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers