note 73416 added to function.header
| From: | php-general at lists dot php dot net | Date: | Thu, 22 Feb 2007 13:34:01 +0000 |
| Subject: | note 73416 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123708@lists.php.net to get a copy of this message | ||
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!
----
Server IP: 194.145.210.4
Probable Submitter: 82.71.67.46
----
Manual Page -- http://www.php.net/manual/en/function.header.php
Edit -- https://master.php.net/note/edit/73416
Del: integrated -- https://master.php.net/note/delete/73416/integrated
Del: useless -- https://master.php.net/note/delete/73416/useless
Del: bad code -- https://master.php.net/note/delete/73416/bad+code
Del: spam -- https://master.php.net/note/delete/73416/spam
Del: non-english -- https://master.php.net/note/delete/73416/non-english
Del: in docs -- https://master.php.net/note/delete/73416/in+docs
Del: other reasons-- https://master.php.net/note/delete/73416
Reject -- https://master.php.net/note/reject/73416
Search -- https://master.php.net/manage/user-notes.php