我想知道是否有任何方法可以使用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下载文件提示
发布评论