Skip to content Skip to sidebar Skip to footer

Sending Generated (jszip) Zip File In Xmlhttprequest (javascript)

i'am design a web application in which i create a set of file from user input, zip them using the JSZip library and then try to post the files to a server using Xhr. The code is th

Solution 1:

use this

var content = zip.generate({type : "blob"});
var server_path = document.getElementById('build_server').value;
server_path = server_path + '/upload_project';
console.log(server_path);
var global_oreq = new XMLHttpRequest();
var file_name = design_name + '.zip';
var formData = new FormData();
var json_build_answer = '';
global_oreq.open("POST", server_path, true);
global_oreq.onload = function(e) {
    // json_build_answer = JSON.parse(oReq.responseText);
console.log('test');
console.log(global_oreq.responseText);
};
formData.append('file', content, file_name);
global_oreq.send(formData);

Post a Comment for "Sending Generated (jszip) Zip File In Xmlhttprequest (javascript)"