title: Redirect to another page if DropzoneJS image upload is success with php variable
body: <p>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</p>
  
  <pre><code>if (!empty($_FILES)) {
   $imgID = submitData()//This functions upload image and write image url in database and then return ID of the affected row
  }
  </code></pre>
  
  <p>When submit button in form is clicked, redirection is happening but $imgID is not getting its value</p>
  
  <p>Here is the Javascript</p>
  
  <pre><code>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 &amp;&amp; myDropzone.getQueuedFiles().length === 0) {
            var idvar = '&lt;?php $imgID; ?&gt;';
      window.location.replace("/preview.php?id="+ idvar);
      }
    });
   }
  }
  </code></pre>
  
  <p>Suggest me where I am doing wrong. Is there any alternative available.</p>