note 73428 deleted from function.header by tularis
| From: | tularis@php.net | Date: | Fri, 20 Apr 2007 14:12:22 +0000 |
| Subject: | note 73428 deleted from function.header by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125621@lists.php.net to get a copy of this message | ||
Note Submitter: Vince <deth AT dethsrealm DOT com>
----
I'm no experienced php programmer, in fact I started less than 4 months ago...but I've
found that to open the save dialog in all browsers I've tried (firefox,navigator, ie6+).
firefox and navigator are the most recent versions available as of the date of this message. I am
unsure about previous versions. I do not know of any php version compatibility issues.
<?php
// set the content as octet-stream
header("Content-Type: application/octet-stream");
// tell the thing the filesize
header("Content-Length: " . filesize("filename.suffix"));
// set it as an attachment and give a file name
header('Content-Disposition: attachment; filename="filename.suffix"');
// read into the buffer
readfile("filename.suffix");
?>
this is converted a bit from code I actually use. I know my code isn't pretty but I've
never really been one to follow code-cleanliness standards, although I know I should. If anyone
finds any issues with this let me know please so I can correct it, but so far it works for me.
I've found that this simplified method will open the save dialog in all of the aforementioned
browsers and that they will be able to display progress. I hope this has been helpful.