简体   繁体   中英

How to forcefully open the file browser to save the file before downloading?

I want my chrome browser to forcefully open dialog box for download(ie Save As). Without manually changing the settings for Downloads in chrome browser. Is there a way doing it using angular js or javascript?

OR

How can I force the chrome browser to open file browser asking where to save the file before downloading using JavaScript and/or AngularJs?

Welcome to SO!

There is no way to do what you're suggesting for security reasons. You don't have rights to choose where the file will go on their OS. JS won't go any deeper than the user's browser. What your asking for is essentially FS (file system) read-write permissions.

Make sure to do a little searching around before you ask new questions, as this one was already answered here: Directory Chooser in HTML page

If I understand your question correctly, then perhaps you are looking for the download attribute on the <a> tag . Note that it is an HTML5 feature and may not be supported by old browsers and that its behavior can be overridden by Content-disposition header in the HTTP response which the server sends.

If you have control of the server, then adding Content-Disposition: attachment; filename="fname.ext" Content-Disposition: attachment; filename="fname.ext" headers to the response can also lead to the browser prompting the user to download the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM