原生jq实现图片上传到服务器

xiaoxiao2021-02-27  239

//示例代码如下所示

//监听图片上传 icon $(document).on('change','#showIconImgDiv',function (e) { var targetElement = e.target,file = targetElement.files[0]; var fd = new FormData(); fd.append('fileToUpload',file); $.ajax({ url : ht.ip.jiaxie + '/uploadaction/addPic', type : 'post', data : fd, contentType : false, processData : false, cache : false, success : function (url) { uploadUrl.url = ht.ip.jiaxieimg + url; console.log(uploadUrl.url); $('.showIconImgLabel').css('background','url('+uploadUrl.url +') center center/cover no-repeat'); } }); }); //url是上传成功返回的 图片在服务器中的地址

转载请注明原文地址: https://www.6miu.com/read-9725.html

最新回复(0)