Iam using laravel 5.4 and dropzone for uploading photos in a form.
I have a form with a lots of inputs. What i want is when the user click the submit button, uploads the photos then send all the inputs names.
My form looks like this:
<form class="form-horizontal" role="form" id="companyForm" method="post" action="{{ route('company.store') }}" enctype="multipart/form-data">
<!-- a lots of inputs fields -->
...
<label>Photos:</label>
<div class="dropzone" id="myDropzone"></div>
<button class="public" type="submit" id="companySubmit">Publish</button>
</form>
my dropzone config:
// initialize dropzone
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone(
"#myDropzone",
{
url: "/company",
method: "post",
uploadMultiple: true,
parallelUploads: 6,
maxFiles: 6,
addRemoveLinks: true,
acceptedFiles: '.jpg,.jpeg,.JPEG,.JPG,.png,.PNG',
autoProcessQueue: false,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
init: function() {
var myDropzone = this;
$('#companyForm').on("submit", function(e) {
if(myDropzone.files.length > 0) {
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
}
});
}
}
);
When click the submit, the files are send but not the inputs fields.
How to send the inputs along the files????