2014-09-22 78 views
0

這是我的代碼:如何用javascript獲取寬度和高度?

function uploadFile(){ 
      var file2 = document.getElementById('file1').files; 
      for(var i = 0; i < file2.length; i++) { 
       var file = file2[i]; 
       var formdata = new FormData(); // This is image 
       formdata.append("file1", file[i]); 
       var ajax = new XMLHttpRequest(); 
       ajax.upload.addEventListener("progress", progressHandler, false); 
       ajax.addEventListener("load", completeHandler, false); 
       ajax.addEventListener("error", errorHandler, false); 
       ajax.addEventListener("abort", abortHandler, false); 
       ajax.open("POST", "file_upload_parser.php"); 
       ajax.send(formdata); 
      } 
     } 

如何從new FormData獲取圖像的寬度和高度? 我需要這個裁剪圖像

回答