Influence browser download destination

走远了吗. 提交于 2019-12-11 04:24:32

问题


is there a way to influence the browsers download directory for a given HTTP download? The scenario is that some of our users are complaining that they have to click through the directory structure whenever they download a file. As I don't know their individual preferences, it would be nice to make the browser use the last chosen download directory. Is this possible? I know that users can choose their download destination from within most browsers' options dialog (firefox, chrome, etc.), but can I influence that behavior from the server side?

Thanks, Mo


回答1:


Server side, no. Your browser client controls where to download in the Preferences/Options (depending what browser you are using).

However, you can via JavaScript. Take a look at this control:

  • ($$) http://www.ardentedge.com/pr_fd.htm

or if you are only using IE, you can use this:

document.execCommand("saveas",false,"c:\\where\\yo u\\want\\to\\save\\it\\to.txt");



回答2:


You can use Content-Disposition to set the filename, as far as I'm aware you can't set the folder as this would be (at least) platform dependent:

header('Content-Disposition: attachment; filename="downloaded.pdf"');



回答3:


It might be possible using a Flash movie, but without resorting to client plugins (using normal HTTP/HTML) this is not possible (mostly for security reasons).

Users can control this in most browsers using their settings.




回答4:


'Classic' web content can't access the local file system. Maybe there is some voodo magic hidden inside ActiveX components or Java applets that would be able to do such a thing, but that could potentially be very complex / restrictive / dangerous.

If there is a routine in which user needs to download which file, you could consider writing a simple HTTP client application that handles the whole process for the user.



来源:https://stackoverflow.com/questions/5597801/influence-browser-download-destination

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!