I am using dropzoneJS in my form. The form also record user input. Below code shows what I am doing in simple. Everything is working fine but php variable is not getting its value. It is somewhat like this
if (!empty($_FILES)) {
$imgID = submitData()//This functions upload image and write image url in database and then return ID of the affected row
}
When submit button in form is clicked, redirection is happening but $imgID is not getting its value
Here is the Javascript
Dropzone.options.myAwesomeDropzone = {
autoProcessQueue: false,
etc.. etc ..
init: function() {
var myDropzone = this;
$("#submit-all").click(function (e) {
e.preventDefault();
e.stopPropagation();
if (myDropzone.files.length) {
myDropzone.processQueue(); // upload files and submit the form
} else {
$('#my-awesome-dropzone').submit(); // submit the form
}
});
// Refresh page when all images are uploaded
myDropzone.on("complete", function (file) {
if (myDropzone.getUploadingFiles().length === 0 && myDropzone.getQueuedFiles().length === 0) {
var idvar = '<?php $imgID; ?>';
window.location.replace("/preview.php?id="+ idvar);
}
});
}
}
Suggest me where I am doing wrong. Is there any alternative available.