note 103837 added to function.readfile

From: Date: Fri, 06 May 2011 03:52:19 +0000
Subject: note 103837 added to function.readfile
Groups: php.notes 
Request: Send a blank email to php-notes+get-179476@lists.php.net to get a copy of this message
If you are lucky enough to not be on shared hosting and have apache, look at installing mod_xsendfile. This was the only way I found to both protect and transfer very large files with PHP (gigabytes). It's also proved to be much faster for basically any file. Available directives have changed since the other note on this and XSendFileAllowAbove was replaced with XSendFilePath to allow more control over access to files outside of webroot. Download the source. Install with: apxs -cia mod_xsendfile.c Add the appropriate configuration directives to your .htaccess or httpd.conf files: # Turn it on XSendFile on # Whitelist a target directory. XSendFilePath /tmp/blah Then to use it in your script: <?php $file = '/tmp/blah/foo.iso'; $download_name = basename($file); if (file_exists($file)) { header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.$download_name); header('X-Sendfile: '.$file); exit; } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 150.148.0.65 ---- Manual Page -- http://www.php.net/manual/en/function.readfile.php Edit -- https://master.php.net/note/edit/103837 Del: integrated -- https://master.php.net/note/delete/103837/integrated Del: useless -- https://master.php.net/note/delete/103837/useless Del: bad code -- https://master.php.net/note/delete/103837/bad+code Del: spam -- https://master.php.net/note/delete/103837/spam Del: non-english -- https://master.php.net/note/delete/103837/non-english Del: in docs -- https://master.php.net/note/delete/103837/in+docs Del: other reasons-- https://master.php.net/note/delete/103837 Reject -- https://master.php.net/note/reject/103837 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179476) next »