Carregar arquivo do sistema de arquivos HTML5 por XMLHttpRequest
Tentando carregar algumas imagens armazenadas no sistema de arquivos do Google Chrome. Mas não consigo carregar a imagem. Alguma idéia de como fazê-lo?
O servidor recebe uma matriz vazia. O código do posttest.php é apenas print_r ($ _ POST)
var xhr = new XMLHttpRequest();
xhr.open('POST', '/posttest.php', true);
xhr.onload = function(e) {
if (this.status == 200) {
console.log(this.responseText);
}
};
window.resolveLocalFileSystemURL(image, function(fileEntry) {
fileEntry.file(function(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
var formData = new FormData();
formData.append('image', this.result);
xhr.send(formData);
};
reader.readAsText(file);
});
});