CSV files open as a page

I am new to web development and I ran into an abnormal problem with CSV files.

I have a link to download a CSV file:

<a href="http://mysite.com/public/sample.csv">Sample CSV file</a> 

On my local machine, it gives a dialog box for loading - this is correct, and that is what I want.

When I upload the same code to my web server, it opens the csv file as a web page in the same browser tab. I don’t want this, I need a dialog box for the download option !

Can someone tell me what I am doing wrong or what I need to do?

+4
source share
1 answer

You can add the following line to your .htaccess. All CSV files will be forced to download if they are open. AddType application/octet-stream csv It will add the MIME header to all csv files, so the browser will understand that it needs to download the file, not show it.

+2
source

All Articles