note 80882 added to function.session-start
| From: | cbake6807 at comcast dot net | Date: | Tue, 05 Feb 2008 16:20:57 +0000 |
| Subject: | note 80882 added to function.session-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135793@lists.php.net to get a copy of this message | ||
Having a problem in IE causing your getFile.php script to be pushed to the browser as an empty text
file, instead of the intended attachment?
If your php config causes session_start() to output a cookie, or anything funky, IE will not like
the filename and will also try and read the file contents inline into the browser window.
Don't use session_start() or USE Output Buffering after the session is started.
<? //session_start();
function force_download($file)
{
if ((isset($file))&&(file_exists($file))) {
$fileArray = explode("/", $file);
header("Content-type: application/force-download");
header("Content-Disposition: attachment;
filename=".$fileArray[sizeof($fileArray)-1]);
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment;
filename=".$fileArray[sizeof($fileArray)-1]);
readfile("$file");
} else {
echo "No file selected";
} //end if
}//end function
?>
----
Server IP: 208.69.120.35
Probable Submitter: 63.164.69.215
----
Manual Page -- http://www.php.net/manual/en/function.session-start.php
Edit -- https://master.php.net/note/edit/80882
Del: integrated -- https://master.php.net/note/delete/80882/integrated
Del: useless -- https://master.php.net/note/delete/80882/useless
Del: bad code -- https://master.php.net/note/delete/80882/bad+code
Del: spam -- https://master.php.net/note/delete/80882/spam
Del: non-english -- https://master.php.net/note/delete/80882/non-english
Del: in docs -- https://master.php.net/note/delete/80882/in+docs
Del: other reasons-- https://master.php.net/note/delete/80882
Reject -- https://master.php.net/note/reject/80882
Search -- https://master.php.net/manage/user-notes.php