note 73416 deleted from function.header by danbrown
| From: | danbrown@php.net | Date: | Sun, 07 Dec 2008 18:17:01 +0000 |
| Subject: | note 73416 deleted from function.header by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147819@lists.php.net to get a copy of this message | ||
Note Submitter:
----
To download anything I tried both the solutions by "Fred p" and by "info /at/
storytellermusic /dot/ nl" but neither worked.
I found that Fred P's solution worked in no browser!
And found that the info solution worked in everything but IE!
In the end I found that the solution which allows you to download any file in any browser is the one
by:
Nick Sterling
25-Jul-2006 06:17
Here's his code again if you can't find it:
<?php
$mm_type="application/octet-stream";
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($url)) );
header('Content-Disposition: attachment;
filename="'.basename($url).'"');
header("Content-Transfer-Encoding: binary\n");
$fp = fopen($url, 'rb');
$buffer = fread($fp, filesize($url));
fclose ($fp);
print $buffer;
?>
Worked in Firefox 2.0.0.1, IE 7 and Opera 9. The downloader even knows the size of the download
which isn't the case with many solutions. Cheers!