标签:java hang inpu load erro upload on() func div
<label> <input type="file" id="upload"> </label>
js
$("#upload").on(‘change‘,function(){ var file = this.files[0]; console.log(this.files); var reader = new FileReader(); //读取文件过程方法 reader.onloadstart = function (e) { console.log("开始读取...."); } reader.onprogress = function (e) { console.log("正在读取中...."); } reader.onabort = function (e) { console.log("中断读取...."); } reader.onerror = function (e) { console.log("读取异常...."); } reader.onload = function (e) { console.log("成功读取...."); var img = "<img src=‘"+e.target.result+"‘>"; $("#upload").parent().before(img); console.log(e.target.result); } reader.readAsDataURL(file) })
####在input框之前插入预览图片
标签:java hang inpu load erro upload on() func div
原文地址:https://www.cnblogs.com/dyy-dida/p/10299490.html