2017-06-13 42 views
1

美好的一天,我已經成功地結合正常的形式懸浮窗和它的作品,但我everytine嘗試使用方法PUT或補丁更新後(用戶內容),我得到錯誤405 (方法不允許)。 後更新工作沒有懸浮窗,但我得到錯誤405(不允許的方法)當添加圖像懸浮窗laravel懸浮窗結合形式的錯誤405(不允許的方法)

  <form id="addproduct" enctype="multipart/form-data" method="POST" action="{{ route('admin.posts.update', $post->id) }}"> 
       {{ csrf_field() }} 
       {{method_field('PATCH')}} 

       <input class="form-control" name="title"> 
       <div id="myAwesomeDropzone" class="dropzone"></div> 
       <button type="button" id="submit_form" class="btn btn-primary">Send</button> 
      </form> 


      <script> 

      Dropzone.options.myAwesomeDropzone = { 
       url: '/admin/posts/{!! json_encode($post->id) !!}', 
       method: 'PUT', 
       autoProcessQueue: false, 
       uploadMultiple: true, 
       parallelUploads: 3, 
       maxFiles: 3, 
       addRemoveLinks: true, 
       thumbnailMethod: 'crop', 
       resizeWidth: 500, 
       resizeHeight: 500, 
       resizeQuality: 0.3, 
       acceptedFiles: ".jpg, .jpeg, .png", 
       dictDefaultMessage: "Drop your files here!", 


       init: function() { 
        var myDropzone = this; 
        $('#submit_form').on("click", function (e) { 
         e.preventDefault(); 
         e.stopPropagation(); 
         myDropzone.processQueue();  
        }); 



        this.on("sending", function(file, xhr, formData){ 
         $('#addproduct').each(function() { 
          title = $(this).find('input[name="title"]').val(); 
          formData.append('title', title); 
         }); 
        }); 
        this.on("success", function(file, response) { 

        }); 
        this.on("completemultiple", function(files) { 
         // Here goes what you want to do when the upload is done 
         // Redirect, reload , load content ...... 

        }); 
       }, 

      }; 

      </script> 

回答

1

試着改變方法POST和附加的_method和_token投入到FORMDATA發送。每次我用的是不是GET,HEAD或POST,我包括這些領域和POST到URL的HTTP動詞。

+0

你是正版的!,謝謝 – netx