Joe,
I have been there....:-)
I use this scripts
<?
function detect_browser($variable)
{
if(eregi("(msie) ([0-9]{1,2}.[0-9]{1,3})", $variable))
{
$content = "ie";
} else {
$content = "nn";
}
return $content;
}
# Send the file to the downloaders browser #
$file_dl = $base_dir.$file;
if (detect_browser($HTTP_USER_AGENT) == "ie") {
Header("Content-type: application/force-download");
} else {
Header("Content-type: application/octet-stream");
}
Header("Content-Length: ".filesize($file_dl));
Header("Content-Disposition: attachment; filename=$file");
Header("Cache-Control: no-cache, must-revalidate"); //HTTP/1.1
Header("Pragma: no-cache"); //HTTP/1.0
readfile($file_dl);
?>
The first time I run this script, I works fine. The file downloads properly
to the client machine with the right size and content. Most of the file is
text file.
After some times, I met the same problem as yours. The file size is 0.
I don't know, perhaps I change the browser setting or my Admin change the
Apache settings, PHP or some thing else.
I ask everywhere, many mailing list. and I gave up.
I just change it to
Header("Location: $url.$filename");
It works but there is a funny things.
The file can be downloaded properly if the file (with such an extension) has
been opened with notepad. If not, the file will opened in the browser.
:-).......it's an experience.....
Gilijk
----- Original Message -----
From: "Joe Van Meer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 19, 2001 10:43 PM
Subject: [PHP] Download File Problem - text not appearing on downloaded file
> Hi there. I managed to get the prompt for a file download when a user
clicks
> on a text link. The file downloads properly to the client machine, howevr,
> when I open up the file there is no content. What do I have to add to the
> following code to get the content sent back to the user?
>
> Thx Joe :)
>
> <?PHP
>
> header("Content-type: application/octet-stream");
> header("Content-Disposition: attachment; filename=file.txt");
>
> ?>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]