html:
<input accept="image/gif,image/jpeg,image/jpg,image/png" type="file" id="up" />
js
$(function() {
$("#up").change(function() {
var file = this.files[0];
if(undefined == file){
return ;
}
var r = new FileReader();
r.readAsDataURL(file);
r.onload = function(e) {
var base64 = e.target.result;
}
});
});
网友评论