私はコントローラのuploadGalleryメソッドでリクエストを受けていません。ただし、投稿要求は正しく受信されます。Dropzone.jsのリクエストをlaravel 5.4
gallery.blade.php
<div class="row">
<form action="{{ url('file-upload') }}" method="post" class="dropzone" id="my-awesome-dropzone">
{{ csrf_field() }}
<div class="dz-message">
<h3>Drop images here or click to upload.</h3>
</div>
</form>
</div>
<script type="text/javascript">
$(function(){
Dropzone.options.myAwesomeDropzone = {
paramName: "files",
uploadMultiple:true,
maxFilesize:6,
autoProcessQueue: true,
uploadMultiple: true,
addRemoveLinks: true,
acceptedFiles: ".png, .jpg, .jpeg",
dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",
dictRemoveFile: "Remove",
dictFileTooBig:"Image is bigger than 6MB",
accept: function(file, done) {
console.log("Uploaded");
done();
},
init:function() {
/* var submitButton = document.querySelector('#submit-all')
myAwesomeDropzone = this;
submitButton.addEventListener("click", function(
myAwesomeDropzone.processQueue();
));
this.on("addedfile", function(){
$('#submit-all').show();
});*/
},
success: function(file,done){
console.log("All files done!");
}
}
});
</script>
web.php
Route::get('/gallery', '[email protected]');
Route::post('/file-upload', '[email protected]');
ImagesController.php
<?php
namespace App\Http\Controllers;
use App\User;
use App\Image;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ImagesController extends Controller
{
public function __construct() {
$this->middleware('auth');
}
public function uploadImages(Image $request) {
$images = request()->file('files');
dd($images);
return view('Gallery');
}
}
なんでもuploadImages関数内は実行されていません。どうして?