标签:details 上传文件 NPU put var com upload txt div
不用form表单:
来源:https://www.cnblogs.com/ilovepan/p/10549236.html
html:
<div class="upload"> <div class="box-upload"> <span>上传图片</span> </div> <input type="file" accept="image/*" name="img" class="uploadImg" value=""> <img src="" alt="" id="imgimg"> </div>
JQUERY:
$(".uploadImg").on("change",function () { var formData = new FormData(); formData.append(‘img‘,this.files[0]) $.ajax({ url:‘/module/controller/uploadImg‘, data:formData, contentType: false, processData: false, type:‘post‘, dataType:‘json‘, success:function (res) { console.log(res) } }) })
如果你要现实页面上(还没有上传到服务器,但是谦容性有点问题)
function phone(a){ var txt=a.files[0]; var src=window.URL.createObjectURL(txt); return src; }
这样就能在没有上传到服务器上之前拿到图片了
用form表单:
来源:https://www.jb51.net/article/142708.htm
和:https://blog.csdn.net/x550392236/article/details/76690927
标签:details 上传文件 NPU put var com upload txt div
原文地址:https://www.cnblogs.com/laijinquan/p/11250011.html