浏览器使用JavaScript下载文件提示

编程入门 行业动态 更新时间:2024-10-26 04:30:38
本文介绍了浏览器使用JavaScript下载文件提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道是否有任何方法可以使用JavaScript实现浏览器的下载文件提示。

I was wondering if there was any method to implement browser's download file prompt using JavaScript.

我的理由 - 用户将上传文件到本地文件服务器,无法从网络服务器访问。换句话说,两者都将在不同的领域!

My reason - well users will be uploading files to a local fileserver which cannot be accessed from the webserver. In other words, both will be on different domains!

例如,假设网站托管在 www.xyz 上,但文件将驻留在本地文件服务器上地址如 \\10.10.10.01\Files\file.txt 。如何使用ActiveX和VBscript上传/传输文件到本地文件服务器! (不要问: - )

For example, let’s say websites hosted on www.xyz, but files would reside on local file server with address like \\10.10.10.01\Files\file.txt. How am I uploading/transferring file to local fileserver... using ActiveX and VBscript! (don’t ask :-)

所以我在我的数据库中存储本地文件路径并将数据绑定到网格。当用户单击该链接时,该文件将在窗口中打开(使用JavaScript)。

So I am storing local file path in my database and binding that data to a grid. When the user clicks on that link, the file opens in a window (using JavaScript).

问题是浏览器窗口中打开的某些文件类型,如text,jpg,pdf等。如何使用客户端脚本实现 content-type 或 content-disposition ?这甚至可能吗?

Problem is certain file types like text, jpg, pdf, etc. open inside browser window. How would I be able to implement content-type or content-disposition using client side scripting? Is that even possible?

编辑:本地文件服务器有一个窗口的共享文件夹,文件保存在该文件夹中。

the local file server has a window's shared folder on which the files are saved.

推荐答案

content-disposition:attachment几乎是强制执行此操作的唯一方法,必须在响应标头中设置。

"content-disposition: attachment" is pretty much the only way to force that, and this MUST be set in the response header.

更多推荐

浏览器使用JavaScript下载文件提示

本文发布于:2023-11-01 20:37:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550351.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:浏览器   提示   文件   JavaScript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!