//示例代码如下所示
//监听图片上传 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是上传成功返回的 图片在服务器中的地址