是否有可能从FTP使用Javascript下载文件? [英] Is it possible to download file from FTP using Javascript?
问题描述
假设,我有一个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)?
- 在一个新的窗口?
- 在一个新的标签在同一个窗口?
- 而不打开一个新窗口或标签?
推荐答案
新窗口或新选项卡由用户的preference控制,并且你不能覆盖。但是,在一个新的标签/窗口中打开您的网址,你会用
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';
这篇关于是否有可能从FTP使用Javascript下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!