Skip to content

Instantly share code, notes, and snippets.

@igauravsehrawat
Created October 23, 2015 04:38
Show Gist options
  • Save igauravsehrawat/cb948385a9272002e70b to your computer and use it in GitHub Desktop.
Save igauravsehrawat/cb948385a9272002e70b to your computer and use it in GitHub Desktop.
function appendAndSendImageHW() {
var allFiles = document.querySelector('input').files;
for (var i = 0; i < allFiles.length; i++) {
var file = allFiles[i];
var newImg = new Image();
newImg.onload = function() {
console.log(newImg.height, newImg.width);
file["height"] = newImg.height;
file["width"] = newImg.width;
}
newImg.src = window.URL.createObjectURL(allFiles[i]);
}
var formElement = document.querySelector("form");
var formData = new FormData(formElement);
var request = new XMLHttpRequest();
request.open("POST", "/api/upload");
formData.append("dummyParamater", "dummyParamater");
request.send(formData);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment