note 43225 added to function.readfile
| From: | EthanJ dot Allison at rn2 dot php dot net | Date: | Mon, 14 Jun 2004 19:22:26 +0000 |
| Subject: | note 43225 added to function.readfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-71062@lists.php.net to get a copy of this message | ||
I use a modified version the following code to allow people to download music from my server without
it opening in Winamp or Musicmatch or WMP or whatever they use. It works perfectly and uses the
minimal amount of needed headers. Thanks to everyone who commented here for helping me figure out
how to do this.
<?php
$file = "http://localhost/file-to-download.xyz";
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($file));
@readfile($file);
?>
----
Manual Page -- http://www.php.net/manual/en/function.readfile.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43225
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43225&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43225&report=yes
Search -- http://master.php.net/manage/user-notes.php