[英]Angular ng-file-upload method PUT not working
我正在使用https://github.com/danialfarid/ng-file-upload來處理我的上傳文件。
但是我在使用方法“ PUT”時遇到問題。
Upload.upload({
url: APIROOT + 'categories/' + $routeParams.id,
data: data,
method: 'PUT'
}).then(function (response) {
ResultService(response.data);
}, function (response) {
ResultService(response.data);
}).finally(function () {
$scope.loading = false;
$scope.button_text = "Update";
});
我的API代碼很簡單(laravel 5.1):
dd($request->all());
在我的服務器上,我無法接收數據。 但是,如果我將方法更改為“ POST”,則可以正確接收它。
有什么辦法嗎?
這與“ laravel”無關。 您無法接收使用“ PUT”方法發送的數據,因為“ ngFileUpload”模塊內部使用“ Form”上載有或沒有數據的圖像,並且Form僅支持“ POST”和“ GET”兩種方法。
請參考以下鏈接以獲取更多說明... 以HTML形式使用PUT方法
解:
使用{_method: 'PUT'}
擴展數據形式,以便Laravel檢測到它需要PUT方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.