更新时间:2023-02-25 12:24:26
不用ajax返回小图的url,直接用js就可以实现,下面是实现代码:
<input type="file" id="imgInp">
<image id="blah" style="width:100px; height:100px;"/>
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function(){
readURL(this);
});