title: Resize images and upload from javascript to php
body: <p>Here is my code: </p>
  
  <pre><code>var data = new FormData();
  var imagesData = "";
  
          $("#filesToUpload").on("change", function(){
              var filesToUpload = document.getElementById("filesToUpload");
              for(var i = 0; i &lt; filesToUpload.files.length; i++){
                  var file = filesToUpload.files[i];
                  var img = new Image(600,400);
                  var reader = new FileReader();
                  reader.onload = function(e){
                      img.src = e.target.result;
                  }
                  reader.readAsDataURL(file);
  
                  var canvas = document.getElementById("canvas");
                  var ctx = canvas.getContext('2d');
  
                  canvas.width = 1600;
                  canvas.height = 900;
  
                  img.onload = function(){
                      ctx.drawImage(img,0,0,canvas.width,canvas.height);
  
                      var dataURL = canvas.toDataURL("image/jpg");
  
                      imagesData += dataURL + "~!!&amp;&amp;!!~";
                  }
              }
  
          })
  
          $("#submit").on("click", function(){
              console.log(imagesData);
              //data.append("imagesData", dataURL);
              //var xhttp = new XMLHttpRequest;
              //xhttp.open("POST", "test.php", true);
              //        
              //xhttp.send(data);
          })
  </code></pre>
  
  <p>I want to resize images in javascript before uploading them to php. I've already managed to resize and upload one file at a time but now I want to do this with multiple files. My plan is to put all the dataURL's into one string and then post that string to php, I'll then split them into an array and continue from there. Now I've tried to log the string in the console before sending it through to php to see if it put the string together correctly but it only contains one dataURL and "~!!&amp;&amp;!!~" separator(which i'm going to use to split the string into an array).</p>
  
  <p>Can anybody shed some light on my situation?</p>