note 39670 added to function.readfile
| From: | covertsonic at earthlink dot net | Date: | Fri, 06 Feb 2004 20:52:37 +0000 |
| Subject: | note 39670 added to function.readfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64742@lists.php.net to get a copy of this message | ||
I found that some of the afforementioned code did not quite meet what i wanted. (I wanted my
playlist.m3u file to not open in the browser, but ask the user where to save to). This was tested in
IE6 and works fine. I used Patrick's code and some from other sources to complete this.
<?PHP
$filename=""; // the name the file will have on client computer
$file_to_download=""; // the name the file has on the server (or an FTP or HTTP request)
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header( "Content-Disposition: attachment; filename=\"$filename\"");
header( "Content-Description: File Transfert");
@readfile($file_to_download);
?>
I'm not sure that the expiration headers were necessary, but it works, and now i'm not
touching it.
----
Manual Page -- http://www.php.net/manual/en/function.readfile.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39670
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39670&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39670&report=yes
Search -- http://master.php.net/manage/user-notes.php