是否可以使用 Javascript 从 FTP 下载文件? [英] Is it possible to download file from FTP using Javascript?

查看:39
本文介绍了是否可以使用 Javascript 从 FTP 下载文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设,我有一个 FTP URL (ftp://xyz.org/file.zip).如果我在浏览器中手动输入,然后按回车,浏览器将开始下载 file.zip 并要求我将其保存在硬盘上.

Suppose, I've a FTP URL (ftp://xyz.org/file.zip). If I type this in the browser manually, then hit enter, the browser will start to download the file.zip and would ask me save it on harddisk.

我的问题是:是否可以在 JavaScript 中编写一个脚本,在运行时应该下载包含所有这些选项的文件(单独)?

My question is: Is it possible to write a script in JavaScript, which when run should download the file with all these options (separately)?

  • 在新窗口中?
  • 在同一窗口的新标签页中?
  • 不打开新窗口或标签页?

推荐答案

新窗口或新标签由用户的偏好控制,您不能覆盖它.但是要在新标签/窗口中打开您的 URL,您可以使用

new window or new tab is controlled by the user's preference, and you can't override that. But to open your URL in a new tab/window you would use

window.open('ftp://xyz.org/file.zip');

在不打开新窗口的情况下请求它

to request it without opening a new window just

window.location = 'ftp://xyz.org/file.zip';

这篇关于是否可以使用 Javascript 从 FTP 下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆