title: Server Responded with code 0 gettting this error with upload dropzone.js
body: <h2>my server side upload Code</h2>
  
  <pre><code>&lt;?php
  header('Access-Control-Allow-Origin: *');
  header('Access-Control-Allow-Methods:GET,POST,PUT,HEAD,DELETE,TRACE,COPY,LOCK,MKCOL,MOVE,PROPFIND,PROPPATCH,UNLOCK,REPORT,MKACTIVITY,CHECKOUT,MERGE,M-SEARCH,NOTIFY,SUBSCRIBE,UNSUBSCRIBE,PATCH');
  header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description,X-PINGOTHER');
  header('Access-Control-Allow-Credentials: true');
  header('Access-Control-Max-Age', '1000');
  date_default_timezone_set('Asia/Kolkata');
  include_once('connection.php');
  
  if(!empty($_FILES)){
  
  //database configuration
  
  $random_digit=rand(0000,9999);
  
  $targetDir = "uploads/";
  $fileName = $_FILES['file']['name'];
  $new_file_name=$random_digit.$fileName;
  $targetFile = $targetDir.$new_file_name;
  
  if(move_uploaded_file($_FILES['file']['tmp_name'],$targetFile)){
      //insert file information into db table
     // mysql_query("INSERT INTO vrecord (file_name, uploaded) VALUES('".$fileName."','".date("Y-m-d H:i:s")."')");
      mysql_query("insert into vrecord(vdate,sid,purpose,remark,nvdate,status,file,submitdate,uid,km) values(str_to_date('$vdate','%d/%m/%Y'),'$sid','$purpose','$remark',str_to_date('$nvdate','%d/%m/%Y'),'$status','$targetFile', NOW(),$uid,$km)");
  }
  </code></pre>
  
  <p>}
  ?></p>
  
  <p>Dropzone code in for upload </p>
  
  <pre><code>var myDropzone = new Dropzone("#myId", {
                  url: 'https://schoolearth.net/myc/upload.php',
                  autoProcessQueue:false,
                  method: "post",
                  withCredentials: true, // For CORS
                  addRemoveLinks: true,
                  maxFiles: 5,
                  maxFilesize: 20,
                  headers: {
                      'x-csrf-token': document.querySelectorAll('meta[name=csrf-token]')[0].getAttributeNode('content').value,
                  },
                  dictDefaultMessage: 'Click To Upload Image',
                  init: function() {
                      console.log('init');
                      this.on("maxfilesexceeded", function (file) {
                          alert("No more files please!");
                          this.removeFile(file);
                      });
                      this.on("sending", function(file, xhr, formData) {
                          formData.append("vdate", $('#req-date').val());
                          formData.append("sid", $('#req-schoolname').val());
                          formData.append("purpose", $('#req-purpose').val());
                          formData.append("remark", $('#req-remark').val());
                          formData.append("nvdate", $('#req-nextdate').val());
                          formData.append("status", $('#req-status').val());
                          formData.append("uid", uid);
                          formData.append("km",$('#req-km').val());
                      });
                      this.on("error", function(file, response) {
                          // do stuff here.
                          alert(response);
  
                      });
                      this.on("success", function(file, responseText) {
                          alert(responseText);
                      });
                      this.on("addedfile", function(file) { fad=1; });
                      this.on("removedfile", function(file) { fad=0; });
                  }
  
  
  
              });
  myDropzone.processQueue();
                      myDropzone.on("complete", function (file) {
                          if (this.getUploadingFiles().length === 0 &amp;&amp; this.getQueuedFiles().length === 0) {
                              var box = bootbox.alert(' &lt;i class="ace-icon fa fa-info-circle bigger-250 green"&gt;&lt;/i&gt;&lt;b class="green" &gt;Visit Record Successfully Submitted..&lt;/b&gt;');
                              box.find(".btn-primary").removeClass("btn-primary").addClass("btn-success");
                              $('#req-date').val('');
                              $('#req-schoolname').val('');
                              $('#req-purpose').val('');
                              $('#req-remark').val('');
                              $('#req-nextdate').val('');
                              $('#req-status').val('');
                              $('#req-km').val('');
                          }
  
                          myDropzone.removeFile(file);
                      });
  </code></pre>
  
  <p>when i click to upload it gives error server responded with code 0,
  One more thing if i add a insert query it works but if i upload any file to server it gives error.</p>