I am currently using a webDav CORS plugin to manage files on a webDav server through POST/PUT/GET/REMOVE/ALLDOCS requests.
Now, I am attempting to achieve the same functionality for FTP but am facing difficulties with the xmlhttprequest
syntax (I keep receiving error code 0
).
According to this page on Mozilla, it is possible to utilize xmlhttprequests
for file transfers and FTP as well. However, I have not been able to locate a functional example or tutorial.
Here is my current attempt, which results in an access to restricted URI denied
error:
function reqListener () {
console.log(this.responseText);
}
var oReq = new XMLHttpRequest();
oReq.onload = reqListener;
oReq.open("GET", "ftp://<username>:<passeword>@mydomain.de/folder/test.txt", true);
oReq.send();
I also tried a standard Ajax request:
$.ajax({
url: "ftp://sharedspace.domain.provider.com/folder/test.txt",
type: "GET",
async: true,
dataType: "text",
crossdomain : true,
headers : {
user: "<username>",
password: "<password>"
},
success: function(e){
console.log("success");
console.log(e);
},
error: function(e){
console.log("error");
console.log(e);
},
});
However, this method also fails and returns a status code of 0
.
Question:
What is the correct syntax for performing a cross-domain XMLHTTPREQUEST
for transferring files via FTP
?
Thank you!
EDIT:
The most helpful resource I encountered was this page here, although it only provides scattered information that I struggled to piece together.
EDIT
Another potentially useful link