FileSaver.js with a dialog

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


FileSaver.js with a dialog



I am using the FileSaver.js to download file using the code below. This file is automatically downloaded to a default folder (Tested in Chrome), but I need to show a window dialog that says something like "Save as file...". Thanks!


var blob = new Blob([data], {type: "application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet"});
saveAs(blob, "file.xlsx");




2 Answers
2



This dialog you are talking about is browser settings specific. Meaning in Google Chrome for example in Settings/Advanced/Downloads section you have a setting:


Settings/Advanced/Downloads



Ask where to save each file before downloading which you can set true/false.


Ask where to save each file before downloading


true/false



If you disable this setting it would always ask you and bring the SaveAs dialog.


SaveAs



Hope this helps.



You can use the prompt method which will prompt the user with a dialog to save the file name.



There are many libraries out there for custom dialogs as well like AlertifyJS or SweetAlert2 which I used in my Flat Design Character Maker.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results