// 文件上传
function uploadHeadpic(){
var formData = new FormData();
formData.append('file', $('#file')[0].files[0]);
formData.append("username",loginUser2.username);
formData.append("uploadIp",returnCitySN["cip"]);
formData.append("uploadLocation",currLocation);
console.log(formData);
//ajax请求
$.ajax({
url:"http://localhost:10004/headpic/upload",
data:formData,
dataType:"text",
type:"post",
// 以下两个属性必须设置!!!!
contentType: false,
processData: false,
success:function (response) {
alert(response.message);
// 刷新历史提头像和当前头像
}
})
}
juery实现文件上传(ajax)
最新推荐文章于 2024-08-30 18:03:30 发布