note 113885 added to function.fread
| From: | dharmilshah at gmail dot com | Date: | Thu, 12 Dec 2013 23:59:46 +0000 |
| Subject: | note 113885 added to function.fread | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197921@lists.php.net to get a copy of this message | ||
For anyone still trying to write an effective file downloader function/script, the work has been
done for you in all the major servers including Apache & nginx.
Using the X-Sendfile header, you can do the following:
if ($user->isLoggedIn())
{
header("X-Sendfile: $path_to_somefile_private");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$somefile\"");
}
Apache will serve the file for you while NOT revealing your private file path! Pretty nice. This
works on all browsers/download managers and saves a lot of resources.
Documentation:
Apache module: https://tn123.org/mod_xsendfile/
Nginx: http://wiki.nginx.org/XSendfile
Lighttpd: http://blog.lighttpd.net/articles/2006/07/02/x-sendfile/
Hopefully this will save you many hours of work.
----
Server IP: 92.48.119.85
Probable Submitter: 23.29.115.134
----
Manual Page -- http://php.net/manual/en/function.fread.php
Edit -- https://master.php.net/note/edit/113885
Del: integrated -- https://master.php.net/note/delete/113885/integrated
Del: useless -- https://master.php.net/note/delete/113885/useless
Del: bad code -- https://master.php.net/note/delete/113885/bad+code
Del: spam -- https://master.php.net/note/delete/113885/spam
Del: non-english -- https://master.php.net/note/delete/113885/non-english
Del: in docs -- https://master.php.net/note/delete/113885/in+docs
Del: other reasons-- https://master.php.net/note/delete/113885
Reject -- https://master.php.net/note/reject/113885
Search -- https://master.php.net/manage/user-notes.php