Javascript代码:
$http({
method: 'POST',
url: 'some/path',
headers: { 'Content-Type': false },
transformRequest: function (data) {
var formData = new FormData();
formData.append("file", data);
return formData;
},
data: file
}).
success(function (data, status, headers, config) {
alert("success!");
}).
error(function (data, status, headers, config) {
alert("failed!");
});
服务器代码:
func addImageHandler(w http.ResponseWriter, r *http.Request) {
c := appengine.NewContext(r)
blobs, _, err := blobstore.ParseUpload(r)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
file := blobs["file"]
....
}
我正在击中处理程序,但是当我解析上传时,我的 blob 映射中没有任何文件。有什么明显的我遗漏了吗?
凤凰求蛊
相关分类