HTML部分
1.首先创建一个本地图片库function getObjectURL(file) {
var url = null;
if(window.createObjectURL != undefined) { // basic
url = window.createObjectURL(file);
} else if(window.URL != undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file);
} else if(window.webkitURL != undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file);
}
return url;
}2.点击function upload() {$("#uploadimg").click();
$("#uploadimg").change(function() {
var imgUrl = getObjectURL(this.files[0]);
$("#img").attr("src", imgUrl);
})
}