How to create an in memory file and upload to server using client side javascript? -


i have test suite written in javascript running in browser runs on embedded system. test suite collects lot of data , want push server. use simple httprequest, post-method, require lot of character escaping send content. simpler upload server file using http-file-upload.

is there way create in memory file , use http-file-upload push server, using client-side javascript?

since browser of embedded system ekioh , system minimal one, technologies such flash, javaapplet, silverlight not available. pure html5 , javascript available.

i think post better way this. dealing escaped data easier, more established problem in-memory files , pushing files server client side javascript. moreover, escaping data done reason. you're trying going welcome lot of security vulnerabilities.

try doing this. snippet taken write javascript output file on server

var data = "...";// data want pass server (could json) //next initiate xmlhttprequest following (could more advanced): var url = "get_data.php";//your url server side file receive data. http.open("post", url, true);  //send proper header information along request http.setrequestheader("content-type", "application/x-www-form-urlencoded"); http.setrequestheader("content-length", params.length); http.setrequestheader("connection", "close");  http.onreadystatechange = function() {//call function when state changes.     if(http.readystate == 4 && http.status == 200) {         alert(http.responsetext);//check if data revived successfully.     } } http.send(data); 

Comments