XHR异步上传文件报错: “the request was rejected because no multipart boundary was found”

js 使用异步上传文件时报错:

报错描述

解决方法:

XHR异步上传文件报错: “the request was rejected because no multipart boundary was found”_第1张图片

// 开始上传
xhr.open("POST", self.url, true);
// xhr.setRequestHeader("Content-Type","multipart/form-data");
xhr.send(formData);

因为请求头的”Content-Type”会自动填充,不需要单独设置header,也就是说,多此一举了。

https://stackoverflow.com/questions/17415084/multipart-data-post-using-python-requests-no-multipart-boundary-was-found

你可能感兴趣的:(javascript)