I have an webDav CORS plugin, which I can use to POST/PUT/GET/REMOVE/ALLDOCS files on a webDav server.
I now want to do the same for FTP, but I\'m struggling to get
oReq.open("PUT", "ftp://`<username`>:`<password`>@mydomain.de/folder/test.txt", true);
req.setRequestHeader('Content-Type', "text/plain");
req.send("Content of test.txt. This will be in test.txt");
I am not totally sure I'm a bit tight on time but I think you could change the files extension to php and add this line of code:
header('Access-Control-Allow-Origin: *');
Then I would just change the mime type like this:
header('Content-type: text/plain');
The header "Access Control" will allow scripts and other files to access the requested file from any domain. Additionally you could put a list of okay domains instead if you wanted to limit access. The header "content type" will allow the file to be read as plain text instead of php there by mirroring a text files behaviour and your users will never know
Although the Mozilla MDN docs reference xmlHttpRequest supporting file and ftp none of the major browsers do AFAIK. It is one of the reasons why you need to serve your web projects from some sort of server, even if it is on the same machine, if you want to develop/test any xmlHttpRequest stuff since file://
doesn't work.
Microsoft specifically states that IE only supports http/https. The W3C spec for it also says that the spec is only for HTTP/HTTPS but that 'some implementations support protocols in addition to HTTP and HTTPS, but that functionality is not covered by this specification'.
As for CORS, it is specifically only for HTTP/HTTPS. The spec is all about using HTTP headers. See the W3C spec here. FTP doesn't have any equivalent type of header as HTTP.