i have in an annonces table a multiple images, i want to update multiple images,I just want to send the data to controller but it gives me error : The PUT method is not supported for this route. Supported methods: POST
.I don't know where the error is.
web.php
Route::post('filesUpdate','AnnoncesController@filesUpdate')->name('filesUpdate');
AnnoncesController.php
public function filesUpdate(Request $request)
{
dd($request->all());
}
details.blade.php
<form method="post" action="{{route('filesUpdate')}}" enctype="multipart/form-data" class="dropzone" id="dropzone">
<input type="hidden" name="_method" value="PUT">
{{ csrf_field() }}
</form>
<script type="text/javascript">
Dropzone.options.dropzone =
{
maxFilesize: 12,
renameFile: function(file) {
var images = [];
$(file).each(function(i){
images[i] = file.name;
console.log(images);
});
$.ajax({
url:"{{ route('filesUpdate') }}" ,
type:'POST',
data:{
images : images,
"_token": "{{ csrf_token() }}"
},
success: function(data, status, xhr){
console.log(data, status, xhr);
},
error: function(xhr, status, msg) {
return console.error(xhr, status, msg)
}})
//return images;
},
acceptedFiles: ".jpeg,.jpg,.png,.gif",
addRemoveLinks: true,
timeout: 50000,
success: function(file, response)
{
console.log(response);
},
error: function(file, response)
{
return false;
}
};
</script>
<input type="hidden" name="_method" value="PUT">
is responsible for method spoofing - means it instructs Laravel to use a PUT method for handling the request.
Since your route is defined as POST
Route::post('filesUpdate','AnnoncesController@filesUpdate')->name('filesUpdate');
Try removing <input type="hidden" name="_method" value="PUT">
from the form to get rid of the error - if it works then it means that your form is not getting submitted via ajax