note 41594 added to function.header

From: Date: Thu, 15 Apr 2004 22:22:47 +0000
Subject: note 41594 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-68181@lists.php.net to get a copy of this message
After banging my days for several days on how exactly to force the browser to ask the visitor to save a file rather than opening it, here's my solution. It works perfectly well for everything including .txt files :)) $output_file = 'something.txt'; $content_len = 666; @ob_end_clean(); @ini_set('zlib.output_compression', 'Off'); header('Pragma: public'); header('Content-Transfer-Encoding: none'); header('Content-Type: application/octetstream; name="' . $output_file . '"'); header('Content-Disposition: inline; filename="' . $output_file . '"'); header("Content-length: $content_len"); See it in action at http://www.motion-hosting.com Really works with all file types! So glad I finally did it! ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41594 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41594&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41594&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68181) next »