There is a model called Image
and it has a file
, title
, photographer
and etc. I need to let the users to upload multiple images, then display the form of other fields for each image. So I chose Dropzone and I need to do it without Ajax upload. This is the form
@extends('layouts.layout')
<link rel="stylesheet" href="{{asset('css/dropzone.css')}}" />
@section('content')
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<div class="widget">
<div class="widget-header">
<span> Multi Image Upload </span>
<i class="icon-picture mr-2"></i>
</div>
<div class="widget-content">
@include('layouts.message')
<SECTION>
<DIV id="dropzone">
{!! Form::open([ 'route' => [ 'images.multiUploadStore' ], 'files' => true, 'enctype' => 'multipart/form-data', 'class' => 'dropzone py-5 px-1 text-center w-100', 'id' => 'image-upload' ]) !!}
<DIV class="dz-message needsclick" id="demo-upload">
Drag and Drop Your Files Here
</DIV>
<div class="mx-auto text-center clearfix col-sm-12">
{{Form::submit('Submit',['class'=>'btn btn-primary','name'=>'submit', 'id'=>'submit'])}}
</div>
{!! Form::close() !!}
</DIV>
</SECTION>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
<script src="{{asset('js/dropzone.js')}}"></script>
<script>
Dropzone.options.imageUpload = {
maxFilesize : 1,
acceptedFiles: ".jpeg,.jpg,.png,.gif"
};
</script>
@endsection
and this is the controller
public function multiuploadstore(Request $request)
{
$images = $request->file('file');
dd($images);
}
and it returns null. How can I access files inside the controller?
Thanks in advance.