note 45908 modified in function.readfile by aidan
| From: | aidan@php.net | Date: | Fri, 24 Sep 2004 01:27:47 +0000 |
| Subject: | note 45908 modified in function.readfile by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77277@lists.php.net to get a copy of this message | ||
If you want to force a download, like Ethan J. Allison, you can better use the local file name
instead of the URL for the file. This way you can avoid some overhead on your webserver.
<?php
$file = '/var/www/html/file-to-download.xyz';
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($filename));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);
?>
--was--
If you want to force a download, like Ethan J. Allison, you can better use the local file name
instead of the URL for the file. This way you can avoid some overhead on your webserver.
<?php
$file = "/var/www/html/file-to-download.xyz";
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($file));
readfile($file);
?>
http://php.net/manual/en/function.readfile.php