on-internet
← Community

Forcing a browser to download a file

Stack Overflow ·

I have a CSV file on my server running PHP. If a user clicks on a link it should download, but instead it opens up in my browser window. My code looks as follows <a href="files/csv/example/example.csv"> Click here to download an example of the "CSV" file </a> It's a normal webserver where I have all of my development work on. I tried something like: <a href="files/csv/example/csv.php"> Click here to download an example of the "CSV" file </a> Now the contents of my csv.php file: header('Content-Type: application/csv'); header('Content-Disposition: attachment; filename=example.csv'); header('Pra

Comments

Sign in or sign up to comment and upvote.

No comments yet.