使用相机上传图片文件上传失败
File upload fails if I use camera to upload a picture
当我尝试从现有文件上传图片时,它工作正常,没有任何问题。但是,当我通过从 camera from mobile 直接点击选择一个文件时,它无法显示“CORS 错误”。我添加了“Access-Control-Allow-Origin”并删除了它 none 其中有帮助。
userData.getRequestCallbackWithPrescription = (req, result) => {
var data = new FormData();
data.append("call_request[call_time]", req.call_time);
req.image_upload.forEach((obj, i) => {
data.append(`prescription_upload[image_upload][${i}][image]`, obj.file, obj.file.name)
})
return $http({
method: "POST",
url: globalUrl + '/api/' + apiVersion + '/customer/web/call_requests',
headers: {
"Access-Control-Allow-Origin": "*",
'Content-Type': undefined,
"X-Auth-Token": $rootScope.UserDetails.Auth,
},
data
})
.then(function (response) {
return result(response.data);
}, function (response) {
return result(response);
});
}
请帮助我找到解决方案。
我刚刚压缩了图片并上传了。有效!
当我尝试从现有文件上传图片时,它工作正常,没有任何问题。但是,当我通过从 camera from mobile 直接点击选择一个文件时,它无法显示“CORS 错误”。我添加了“Access-Control-Allow-Origin”并删除了它 none 其中有帮助。
userData.getRequestCallbackWithPrescription = (req, result) => {
var data = new FormData();
data.append("call_request[call_time]", req.call_time);
req.image_upload.forEach((obj, i) => {
data.append(`prescription_upload[image_upload][${i}][image]`, obj.file, obj.file.name)
})
return $http({
method: "POST",
url: globalUrl + '/api/' + apiVersion + '/customer/web/call_requests',
headers: {
"Access-Control-Allow-Origin": "*",
'Content-Type': undefined,
"X-Auth-Token": $rootScope.UserDetails.Auth,
},
data
})
.then(function (response) {
return result(response.data);
}, function (response) {
return result(response);
});
}
请帮助我找到解决方案。
我刚刚压缩了图片并上传了。有效!