note 41810 deleted from function.header by danbrown

From: Date: Sun, 07 Dec 2008 18:34:28 +0000
Subject: note 41810 deleted from function.header by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147839@lists.php.net to get a copy of this message
Note Submitter: motion at abv dot bg ---- In response to Martin Anso and for your benefit, here's an even better routine for forcing the browser to save a file, rather than opening it. ----------- $f = fopen("file.txt", "rb"); $content_len = (int) filesize($f, "file.txt"); $content_file = fread($f, $content_len); fclose($f); $output_file = 'something.txt'; @ob_end_clean(); @ini_set('zlib.output_compression', 'Off'); header('Pragma: public'); header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header('Content-Transfer-Encoding: none'); header('Content-Type: application/octetstream; name="' . $output_file . '"'); //This should work for IE & Opera header('Content-Type: application/octet-stream; name="' . $output_file . '"'); //This should work for the rest header('Content-Disposition: inline; filename="' . $output_file . '"'); header("Content-length: $content_len"); echo $content_file; exit();

« previous php.notes (#147839) next »