Please make sure that you added the encoding type to your form
enctype="multipart/form-data"
<form action="action.php" method="post" enctype="multipart/form-data">
<!-- form input fields here -->
</form>
in my laravel application I am using dropzone programmatically to upload images. this is my Controller to store images in VehicleController
$photos = $request->file('file');
dd($photos);
if (!is_array($photos)) {
$photos = [$photos];
}
if (!is_dir($this->photos_path)) {
mkdir($this->photos_path, 0777);
}
for ($i = 0; $i < count($photos); $i++) {
$photo = $photos[$i];
$name = sha1(date('YmdHis') . str_random(30));
$save_name = $name . '.' . $photo->getClientOriginalExtension();//this is line 75
$resize_name = $name . str_random(2) . '.' . $photo->getClientOriginalExtension();
Image::make($photo)
->resize(250, null, function ($constraints) {
$constraints->aspectRatio();
})
->save($this->photos_path . '/' . $resize_name);
$photo->move($this->photos_path, $save_name);
$upload = new Upload();
$upload->filename = $save_name;
$upload->resized_name = $resize_name;
$upload->original_name = basename($photo->getClientOriginalName());
$upload->save();
}
return Response::json([
'message' => 'Image saved Successfully'
], 200);
and programatically jquery is
Dropzone.autoDiscover = false;
// Dropzone class:
var myDropzone = new Dropzone("div#my-dropzone", { url: '/form'});
routes
Route::post('form','VehicleController@store');
My blade file is
<div class="dropzone" id="my-dropzone">
<div class="dz-message">
<div class="col-xs-8">
<div class="message">
<p>Drop files here or Click to Upload</p>
</div>
</div>
</div>
<div class="fallback">
<input type="file" name="file" multiple>
</div>
</div>
but with this div class
<div class="fallback">
<input type="file" name="file" multiple>
</div>
images submitting out comes null value with dd(photos);
but without above div class="fallback" dropzone box is working but with single image uploading. then how can fix multiple images uploding null values outcomes?
Please or to participate in this conversation.