html单张图片效果,jquery+html5实现单张图片上传预览
js:
if (window.File && window.FileReader && window.FileList && window.Blob){
//Blob是計(jì)算機(jī)界通用術(shù)語(yǔ)之一,全稱(chēng)寫(xiě)作:BLOB (binary large object),表示二進(jìn)制大對(duì)象。
//全部支持
function handleFileSelect(evt) {
var files = evt.target.files, f = files[0];
if (!/image\/\w+/.test(f.type)){
alert("請(qǐng)確保文件為圖像類(lèi)型");
return false;
}
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
var show_pic = document.getElementById("show_pic");
show_pic.src = e.target.result;
};
})(f);
reader.readAsDataURL(f);
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
}else {
alert('該瀏覽器不全部支持File APIs的功能');
}
html:
總結(jié)
以上是生活随笔為你收集整理的html单张图片效果,jquery+html5实现单张图片上传预览的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: excel vba移位运算
- 下一篇: 残差网络(ResNet)