note 56304 deleted from function.header by sean

From: Date: Tue, 30 Aug 2005 23:57:57 +0000
Subject: note 56304 deleted from function.header by sean
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-94465@lists.php.net to get a copy of this message
Note Submitter: daves at datriware dot com ---- If you want to force download large files, you will not fall into memory_limit with this script : if (!is_file($file)) { die("<b>404 File not found!</b>"); } $len = filesize($file); $filename = basename($file); $file_extension = strtolower(substr(strrchr($filename,"."),1)); header('Content-type: application/force-download'); header('Pragma: public'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.$len); header('Location: '.$file); $chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $handle = fopen($file, 'rb'); if ($handle === false) { die("Handle not received"); } while (!feof($handle)) { $buffer = fread($handle, $chunksize); echo $buffer; flush(); } exit;

« previous php.notes (#94465) next »