Why isn't dropzone submitting a file?

610 views Asked by At

I have a form with dropzone that needs to upload an image and two text inputs. The text inputs are sent through fine but the file is not.

Can somebody tell what I am missing?

This is my form:

<div id="dropzone">
        <form action="" id="dropzoneForm" method="post" enctype= multipart/form-data>
            <input type="hidden" name="_token" value="{{ csrf_token() }}">
            <div class="dz-message">
                <h3 style="">Drag file here or click to upload</h3>
            </div>

            <div class="input-container">
                <div class="input-group">
                    <span class="input-group-addon">Name</span>
                    <input type="text" name="name">
                </div>
                <div class="input-group">
                    <span class="input-group-addon">Categories</span>
                    <input type="text" name="categories"><span> (Comma separated)</span>
                </div>
                <button type="submit" value="Submit" class="upload-submit-button btn btn-success">
                    <i class="glyphicon glyphicon-upload"></i>
                    <span>Submit</span>
                    </button>
            </div>
        </form>
    </div>

And this is my jQuery script to configure the dropzone:

        $(document).ready(function(){

        Dropzone.autoDiscover = false;

        $('#dropzoneForm').dropzone({

            autoProcessQueue: true,
            acceptedFiles: "image/*",

            paramName: "design",
            url: "{{ url('/submit') }}",

            thumbnailWidth: 500,
            thumbnailHeight: 250,
            maxFiles: 1,

            accept: function (file, done){
                console.log('Success for ' + file.name);
                console.log('Processing queue');
                done();
            }
        });
    });

If I dump the submitted data there is a name field and a categories field but no file or design!

1

There are 1 answers

0
Matthias On

Turned out to be the action on the form, this does need a URL. I thought I only had to configure this in the dropzone configuration.

<form action="{{ url('/submit') }}" id="dropzoneForm" method="post" enctype= multipart/form-data>