Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download csv files using Javascript on Safari

I have generated a CSV file using Javascript. When the user clicks a link, the CSV file has to be downloaded to his PC with a proper filename.

I am using HTML5 'Download' attribute in tag to provide the filename, but Safari does not acknowledge this as it has not implemented the 'Download' feature yet. This results in the download filename to be named as 'Unknown'.

Is there any other way to generate a download while retaining the filename?

like image 994
Souji Avatar asked Feb 25 '26 13:02

Souji


1 Answers

I completed a quick research - I looks like Safari does not supports what you are looking to accomplish.

The reason behind why your answer works in Chrome (and Firefox) is that they bolster the download property - Safari doesn't yet. Safari 10.1+ supports "download" attribute

like image 66
Muhammad Adeel Malik Avatar answered Feb 28 '26 02:02

Muhammad Adeel Malik