Is it possible to download file from FTP using Javascript?(是否可以使用 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 下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否可以使用 Javascript 从 FTP 下载文件?
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Fetch API 如何获取响应体? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01