javascript - Upload file from HTML5 Filesystem by XMLHttpRequest -


Trying to upload some images stored in Google Chrome's file system. But I am not able to upload the image. How to do an idea?

The server receives empty arrays. The code of posttest.php is print_a ($ _ 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) {var reader = new fileReader (); reader.onloadend = function {E} {var formData = new FormData (); formData.append (' Image ', this.result); xhr.send (formData);}; reader.readAsText (file);});});    

This is a JavaScript function that worked for me in Chrome

Function Upload (filename) {var xhr = new XMLHttpRequest (); Xhr.open ("post", "upload.fp", true); Window.resolveLocalFileSystemURL = window.resolveLocalFileSystemURL || Window.webkitResolveLocalFileSystemURL; File name = 'filesystem: http: // localhost / temporary' 'file name; Window.resolveLocalFileSystemURL (file name, function {fileEntry} {fileEntry.file} {xhr.setRequestHeader ("content type", "multiparty / form-data"); xhr.setRequestHeader ("x-file-name" , File.name); xhr.setRequestHeader ("x-file-size", file.size); xhr.setRequestHeader ("x-file-type", file.type); xhr.send (file);}); }); }

Most people except upload.php are taking it to take. But this is very important and so I am pasting it here:

Hope it helps someone, I ruined it to understand it all day!

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -