I have a fake profile system for a class project, it requires a profile picture, and it needs an option to change it locally (from your hard drive). I have a working i
There's FileReader.readAsDataURL (see Indra's answer) and also window.URL.createObjectURL:
function changePicture() {
//open the open file dialog
document.getElementById('upload').click();
document.getElementById('upload').onchange = function() {
var file = this.files[0];
var url = window.URL.createObjectURL(file);
document.getElementById('image').src = url;
};
}