对 FTP 服务器执行跨域 XMLHTTPREQUEST 的语法是什么

What is the syntax to do a cross-domain XMLHTTPREQUEST to an FTP server?(对 FTP 服务器执行跨域 XMLHTTPREQUEST 的语法是什么?)

本文介绍了对 FTP 服务器执行跨域 XMLHTTPREQUEST 的语法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 webDav CORS 插件,可用于在 webDav 服务器上 POST/PUT/GET/REMOVE/ALLDOCS 文件.

I have an webDav CORS plugin, which I can use to POST/PUT/GET/REMOVE/ALLDOCS files on a webDav server.

我现在想为 FTP 做同样的事情,但我正在努力让 xmlhttprequest-syntax 工作(我只是收到错误 0 ).

I now want to do the same for FTP, but I'm struggling to get the xmlhttprequest-syntax to work (I'm just getting error 0 ).

Mozilla 上的这个页面说这是可能的也可以将 xmlhttprequests 用于文件和 ftp,但我在任何地方都找不到工作示例或教程.

This page on Mozilla says it's possible to use xmlhttprequests for file and ftp as well, but I cannot find a working example or tutorial anywhere.

这就是我正在尝试的,它返回 access to restricted URI denied

This is what I'm trying, which returns access to restricted URI denied

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();

我也尝试了一个常规的 Ajax 请求

I also tried a regular 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);
  },
}); 

这也不起作用,返回0状态码.

which also does not work, returning 0 status code.

问题:
FTP 执行跨域 XMLHTTPREQUEST 的正确语法是什么.

Question:
What is the correct syntax to do a cross-domain XMLHTTPREQUEST for FTP.

谢谢!


我发现的唯一有用的链接是这个页面 这里, 但这只是零碎的信息,我无法将它们拼凑在一起.


The only useful link I found is this page here, but it's just bits and pieces of information and I couldn't puzzle them together.

编辑
也许也有用 链接

推荐答案

虽然 Mozilla MDN 文档引用了 xmlHttpRequest 支持文件和 ftp,但没有一个主流浏览器执行 AFAIK.如果您想开发/测试任何 xmlHttpRequest 自 file:// 不工作.

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 明确声明 IE 仅支持http/https.它的 W3C 规范还说 该规范仅适用于 HTTP/HTTPS 但某些实现支持协议除了 HTTP 和 HTTPS,但本规范未涵盖该功能.

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'.

对于 CORS,它专门用于 HTTP/HTTPS.该规范是关于使用 HTTP 标头的.请参阅此处的 W3C 规范.FTP 没有任何与 HTTP 等效的标头类型.

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.

这篇关于对 FTP 服务器执行跨域 XMLHTTPREQUEST 的语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:对 FTP 服务器执行跨域 XMLHTTPREQUEST 的语法是什么

基础教程推荐