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.

5
  • Does the form actually post, I mean if you watch network tab of devtools do you see the post happen, with the file? Commented Sep 6, 2018 at 4:37
  • @Don'tPanic Yes I can see the submit button when I dd($request) Commented Sep 6, 2018 at 4: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 Commented Sep 6, 2018 at 4:43
  • @Don'tPanic I don't want it to upload automatically. Commented Sep 6, 2018 at 4:50
  • 1
    please go through this webtips.krajee.com/question/dropzone-without-ajax-upload and this stackoverflow.com/questions/38712072/… . Hope its helpful to you. Commented Sep 6, 2018 at 5:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.