note 32112 deleted from function.fread by cmb

From: Date: Sun, 12 Jan 2020 08:19:26 +0000
Subject: note 32112 deleted from function.fread by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213847@lists.php.net to get a copy of this message
Note Submitter: Brian ---- Two quick notes on download prompting... First, the following line: <?php header("Cache-Control: no-cache, must-revalidate"); ?> causes IE6 to prompt you to download the script instead of the output and will fail to connect. Take out that header and everything works perfectly. Pragma: no-cache doesn't cause a problem. Second, Mozilla tries to add .php to the download file name if content-type is application. Changing the content type to the more specific MIME type (such as audio/mpeg) fixes that but causes IE to try its plugins (such as Quicktime). The fix I found for that to specify attachment instead of inline. Here's my code: a prompted, small buffer MP3 download: <?php function downloadMP3 ($fileDir, $fileName) { $completeFilePath=$fileDir.'/'.$fileName; header('Pragma: no-cache'); header("Content-type: audio/mpeg\nContent-Disposition: attachment; filename=\"" . $fileName . "\"\nContent-length: ".(string)(filesize($completeFilePath))); $fd=fopen($completeFilePath,'rb'); while(!feof($fd)) { print(fread($fd, 4096)); flush(); } } ?>

« previous php.notes (#213847) next »