dmhouse Posted July 10, 2008 Share Posted July 10, 2008 Hi all. I'm trying to write a script to force the download of a file. I understand the correct way to do this is by means of the Content-disposition header; indeed, I've had success in Firefox 3, IE 6 & 7 with the following: <?php header('Content-disposition: attachment; filename="test.txt"'); header('Content-type: text/plain'); header('Content-length: 2'); echo 'yo'; ?> However nearly every resource I see on the internet advocates the usage of some kind of spoofed Content-type header, e.g. application/octet-stream, application/download, application/x-download etc. Does anyone know whether this is necessary for certain browsers, or can I get away with just Content-disposition? Link to comment https://forums.phpfreaks.com/topic/114046-forcing-downloads-content-type-header-necessary/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.