function handleFiles(files) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
var imageType = /image.*/;
if (!file.type.match(imageType)) {
continue;
}
var img = document.createElement("img");
img.classList.add("obj");
img.file = file;
$('#file').before(img); // Assuming that "preview" is a the div output where the content will be displayed.
var reader = new FileReader();
reader.onload = (function(aImg) { return function(e) { aImg.src = e.target.result; }; })(img);
reader.readAsDataURL(file);
var form = new FormData();
form.append('photoCategory', file);
var xhr = new XMLHttpRequest();
xhr.onload = function(data) {
console.log(data.currentTarget.responseText);
console.log("Отправка завершена");
};
xhr.open("post", "/adminpro/File_Upload", true);
xhr.send(form);
}
}
Спасибо!