Created
August 13, 2013 07:43
-
-
Save zhoufenfens/6218757 to your computer and use it in GitHub Desktop.
file uploader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function changehandler(){ | |
console.log("change"); | |
var file = document.getElementById('fileupload').files[0]; | |
var reader=new FileReader(); | |
reader.onload = (function(theFile) { | |
return function(e) { | |
console.log(e.target.result); | |
// img 元素 | |
document.getElementById("img").src = e.target.result; | |
}; | |
})(file); | |
reader.readAsDataURL(file); | |
} | |
document.getElementById("fileupload").addEventListener("change",changehandler,false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment