How to create download links for CSV file downloading in Safari browsers?
Right now download link is this:
<a href="http://localhost/uploads/user-import-template/SupportUs_user_import.csv">download CSV template</a>
Problem is that this link opens CSV file in same browser tab, instead of downloading it.
Just add the download
attribute:
<a download="SupportUs_user_import.csv"
href="http://www.example.com/SupportUs_user_import.csv">download CSV template</a>
Please note it's an attribute new in HTML 5 and it may not be supported in some browsers. Where unsupported (you can check client-side with modernzr) you must use server side code to add "Content-Disposition"
HTTP header with "attachment; filename=SupportUs_user_import.csv"
. If your file is static you can also configure your web server to add that HTTP header.
Currently (2017) it's not supported by IE11, desktop Safari before version 10.1, Safari for iOS and Opera Mini (source: Can I use...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With