显示上传图片

it2022-05-05  173

不用等图片上传到服务器就可以预览上传图片的代码(blob对象)

部分html代码

<input type="file" id="upload" accept="image/*" name="file" /> 

<div id="showFile"></div>

js代码

$("#upload").on("change",function(){  

var ts=this;var blob_=new Blob([ts.files[0]],{type:"application/octet-binary"});var url=URL.createObjectURL(blob_);var img = "<img class='man-w33 left' src='"+url+"' />";$("#showFile").append(img);

});

 

转载于:https://www.cnblogs.com/Ushadow/p/7068800.html


最新回复(0)