2

I'm using https://github.com/danialfarid/ng-file-upload for handle my uploading file.

But i got problem when i'm using method: "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";
   });

my API Code just simply (laravel 5.1) :

   dd($request->all());

At my server i can't receive the data. But if i change method to "POST" i can receive it properly.

Any solution?

ssuhat
  • 7,387
  • 18
  • 61
  • 116

2 Answers2

0

This is not an issue related to "laravel". You are not able to receive the data which has been sent using "PUT" method because "ngFileUpload" module internally uses "Form" to upload image with or without data and Form supports only two methods "POST" & "GET".

Please refer the following link for more clarification... Using PUT method in HTML form

Community
  • 1
  • 1
0

Solution:

extend data form with {_method: 'PUT'} so Laravel will detect it want PUT method.

ssuhat
  • 7,387
  • 18
  • 61
  • 116