php - Upload a File from the Google Chrome File System to a Server -


chrome has useful file system api using. trying upload file stored within server. unfortunately, seems way 1 can send file server submitting form wherein user explicitly chooses file upload because of security issues.

any appreciated.

peter


so have idea. why not convert blob string using filereader , send in body of request?

//entries[] contains set of file objects function readersuccess(entries) {    var i;    (i=0; i<entries.length; i++)     {        if(entries[i].isfile === true)        {         data=new formdata();     data.append('name',entries[i].fullpath);      //conversion...     entries[i].file(function(file) {             var reader = new filereader();              reader.onloadend = function(e) {             var datastr=this.result;              };          reader.readastext(file);      }, errorhandler);     //sending...  data.append('file',datastr);  var oreq = new xmlhttprequest();  oreq.open("post", "serv.php", true);  oreq.send(data);       }     else if (entries[i].isdirectory === true)     {     getdirsuccess(entries[i]);     }   }  } 

the problem it's sending blobs separate messages. example: request url:blob:http%3a//localhost/7492a164-ed62-4834-939c-e6437b52cba8 request method:get status code:200 ok (from cache)

i'm not entirely sure why using filereader here. append each blob/file formdata object , send it:

var data = new formdata(); if(entries[i].isfile) {    data.append('file' + , entries[i]); }  var oreq = new xmlhttprequest(); oreq.open("post", "serv.php", true); oreq.send(data); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -