jquery - Downloading and then uploading files with JavaScript -
now first of all, i'm making userscript, meaning don't own servers download files or servers upload files.
so need download file server (needs type, not text files), , somehow submit file file upload form on website. possible? @ first wondering if i'd able submit file directly 1 server other, don't think that's possible.
so there way can this? can use jquery well.
as long won't blocked xss prevention, load data using xmlhttprequest post other site.
here basic functional example:
var xhr = new xmlhttprequest(); xhr.open("get", "http://www.example.com/file", true); xhr.onload = function () { xhr.close(); var xhr2 = new xmlhttprequest(); xhr2.open("post", "http://www.example2.com/form", true); xhr2.send(xhr.response); } xhr.send();
i advise add code catch errors
for more details on xmlhttprequests, documentation can found on mdn here, instructions on how use on mdn here
Comments
Post a Comment