Im trying to get dropzone.js working with multiple input and select fields working.
Also reading the dropzone.js documentation i saw that the dropzone form looks like a stand alone form. So when i tried to add more input and select fields inside the dropzone form, the complete form gets covered by a dropzone, and i wanted just one part to be a dropzone. Also i found i way fixing it reading other stackoverflow articles.
What i did is i created a form with 3 input fields, 7 select options and + 1 dropzone, and i have 1 submit button which should submit it all together.
I have followed this stackoverflow article: Integrating Dropzone.js into existing HTML form with other fields
Problem: When I submit the form the file starts uploading (Progress animation shows it) but the file gets not uploaded to the server, and the form gets not completly submited, also the fields values are not sent to the database.
This is the form start code:
<form id="drform" name="formapdf2" method="post" action="dodaj-save.php" autocomplete="off" enctype="multipart/form-data">
This is the submit button code:
<button id="sbmtbutton" class="btn btn-primary" name="insert" type="submit">Registruj radnika</button>
Here is the JS code i use:
Dropzone.options.dropfile = {
acceptedFiles: 'image/*',
maxFiles: 1,
resizeWidth: 300,
resizeHeight: 300,
resizeMethod: 'contain',
resizeQuality: 1.0,
maxFilesize: 4,
autoProcessQueue: false,
url: 'dodaj-save.php',
addRemoveLinks: true,
init: function() {
dzClosure = this; // Makes sure that 'this' is understood inside the functions below.
// for Dropzone to process the queue (instead of default form behavior):
document.getElementById("sbmtbutton").addEventListener("click", function(e) {
// Make sure that the form isn't actually being sent.
e.preventDefault();
e.stopPropagation();
dzClosure.processQueue();
});
//send all the form data along with the files:
this.on("sendingmultiple", function(data, xhr, formData) {
formData.append("name", jQuery("#dzfname").val());
formData.append("qrcode", jQuery("#dzfqrcode").val());
formData.append("company", jQuery("#select_id").val());
formData.append("money", jQuery("#dzfmoney").val());
formData.append("checkin", jQuery("#dzfcheckin").val());
formData.append("checkout", jQuery("#dzfcheckout").val());
formData.append("checkin1", jQuery("#dzfcheckin1").val());
formData.append("checkout1", jQuery("#dzfcheckout1").val());
formData.append("checkin2", jQuery("#dzfcheckin2").val());
formData.append("checkout2", jQuery("#dzfcheckout2").val());
});
}
}
I have the PHP code for upload too, but im not sure if the php code is the problem, and should i show this code too here. If you need anything else to identify what is the problem please let me know. And I hope i didnt break any stackoverflow rule since this is my first post.