文件上传 :form-data格式
2018-05-28 本文已影响0人
岳小弟
//HTML
<div class="beacone_right-btn autoM" onclick="uploadPic();">立即缴纳</div>
<input type="file" name="file" id="pic" />
//formData上传文件
function uploadPic() {
var formData = new FormData()
formData.append("file", $('#pic')[0].files[0])
console.log($('#pic')[0].files)
console.log(formData)
$.ajax({
url: "/member/upload",
type: "post",
data: formData,
processData: false,
contentType: false,
success: function (res) {
console.log(res)
}
})
}