0

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.

M a m a D
  • 1,938
  • 2
  • 30
  • 61
  • Does the form actually post, I mean if you watch network tab of devtools do you see the post happen, with the file? – Don't Panic Sep 06 '18 at 04:37
  • @Don'tPanic Yes I can see the submit button when I `dd($request)` – M a m a D Sep 06 '18 at 04:39
  • 1
    Submit button? Dropzone auto-uploads by default, ie you don't get to click submit, the file will be POSTed as soon as you drop it. If that's not what you want, you need to disable that behaviour - [check out this answer for a guide on doing that](https://stackoverflow.com/questions/46728205/dropzone-submit-button-on-upload/46732882#46732882) – Don't Panic Sep 06 '18 at 04:43
  • @Don'tPanic I don't want it to upload automatically. – M a m a D Sep 06 '18 at 04:50
  • 1
    please go through this http://webtips.krajee.com/question/dropzone-without-ajax-upload/ and this https://stackoverflow.com/questions/38712072/laravel-dropzone-file-not-uploading . Hope its helpful to you. – syam Sep 06 '18 at 05:05

0 Answers0