note 74884 added to function.header

From: Date: Wed, 02 May 2007 08:53:37 +0000
Subject: note 74884 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-126114@lists.php.net to get a copy of this message
More on downloading files... Here's a slight improvement to the method provided by Nick Sterling. I tried this and it works great, but using fopen ran into memory limit problems. By using readfile($filename), I solved this problem without having to change the ini settings. readfile() reads a file and writes it to the output buffer. Here's my version of the code: <?php $filename = "theDownloadedFileIsCalledThis.mp3"; $myFile = "/absolute/path/to/my/file.mp3"; $mm_type="application/octet-stream"; header("Cache-Control: public, must-revalidate"); header("Pragma: hack"); // WTF? oh well, it works... header("Content-Type: " . $mm_type); header("Content-Length: " .(string)(filesize($myFile)) ); header('Content-Disposition: attachment; filename="'.$filename.'"'); header("Content-Transfer-Encoding: binary\n"); readfile($myFile); ?> ---- Server IP: 130.206.1.5 Probable Submitter: 217.126.92.126 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/74884 Del: integrated -- https://master.php.net/note/delete/74884/integrated Del: useless -- https://master.php.net/note/delete/74884/useless Del: bad code -- https://master.php.net/note/delete/74884/bad+code Del: spam -- https://master.php.net/note/delete/74884/spam Del: non-english -- https://master.php.net/note/delete/74884/non-english Del: in docs -- https://master.php.net/note/delete/74884/in+docs Del: other reasons-- https://master.php.net/note/delete/74884 Reject -- https://master.php.net/note/reject/74884 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126114) next »