Implementing file download links
It's amazing how many basic web developer techniques I still don't know.
I want to provide a file download link. But the URL is not a static path like
http://some.server.com/some_file.csv
Instead it points to an ASP.NET or PHP page, e.g.
http://some.server.com/Download.aspx?item=blah
http://some.server.com/download.php?item=blah
And it returns dynamically-generated, plain-text, comma-separated-value content.
How do I convince Safari to download the file, rather than simply loading it in the browser window? How do I convince Firefox that the downloaded content is really
text/csv
and not a file of type php
or aspx
?The answer, courtesy of the online PHP manual: use a content-disposition header.
To find the details, go to the PHP manual page and search for "Content-Disposition".
No comments:
Post a Comment