JS> FTP>网站目录>文件列表

发布于 2024-09-09 03:25:08 字数 74 浏览 0 评论 0原文

是否可以使用 Javascript 调用对指定 URL 的 FTP 调用并检索此 Web 目录中的所有文件?

...

Is it possible to use Javascript to invoke a FTP call to a specified URL and retrieve all files in this webdirectory?

...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

轮廓§ 2024-09-16 03:25:08

假设您正在谈论浏览器中的 javascript,那么如果没有一些支持的服务器端代码,这是不可能的。

您可以使用 javascript 对服务器进行 ajax 调用 - 服务器可以调用 FTP 并将文件列表(甚至文件)检索到服务器。然后可以从服务器下载这些。

Assuming you are talking about javascript in the browser, then this is not possible without some supporting server side code.

You can use javascript to make an ajax call to a server - the server can invoke FTP and retrieve a file list (or even the files) to the server. These can then be downloaded from the server.

熊抱啵儿 2024-09-16 03:25:08

9年后,事情变得容易多了。
这是一个独立的 Node.js 示例,展示了当今如何使用 javascript 轻松实现服务器端的事情。

npm install
node index.js

index.js

// Test getting CSV Data from Deutscher Wetterdienst
const ftp = require('ftp')

var Client = require('ftp');

var c = new Client();
c.on('ready', function() {
  c.list('/pub/CDC/derived_germany/soil/daily/recent/',function(err, list) {
    if (err) throw err;
    console.dir(list);
    c.end();
  });
});
// connect to localhost:21 as anonymous
c.connect({host:'ftp-cdc.dwd.de'});

package.json

  {
      "name": "ftp-test",
      "version": "1.0.0",
      "description": "ftp Test application",
      "main": "index.js",
      "dependencies": {
        "ftp": "^0.3.10"
      },
      "devDependencies": {},
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "Wolfgang Fahl",
      "license": "ISC"
    }

9 years later things are much easier.
Here is a standalone node.js example that shows how on the server side thing can be implemented with javascript theses days easily.

npm install
node index.js

index.js

// Test getting CSV Data from Deutscher Wetterdienst
const ftp = require('ftp')

var Client = require('ftp');

var c = new Client();
c.on('ready', function() {
  c.list('/pub/CDC/derived_germany/soil/daily/recent/',function(err, list) {
    if (err) throw err;
    console.dir(list);
    c.end();
  });
});
// connect to localhost:21 as anonymous
c.connect({host:'ftp-cdc.dwd.de'});

package.json

  {
      "name": "ftp-test",
      "version": "1.0.0",
      "description": "ftp Test application",
      "main": "index.js",
      "dependencies": {
        "ftp": "^0.3.10"
      },
      "devDependencies": {},
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "Wolfgang Fahl",
      "license": "ISC"
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文