RE: [PHP] Problem using readfile
| From: | Fernando Madruga | Date: | Fri, 09 Mar 2001 10:02:57 +0000 |
| Subject: | RE: [PHP] Problem using readfile | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-5899@lists.php.net to get a copy of this message | ||
What are the contents of $type? When opening the file directly, the browser
will probably use the specified $type information, as opposed to the
explorer using the file extension when the user saves it to disk, so the
problem may be that $type is not correct... ;)
HTH,
Fernando Madruga
-----Original Message-----
From: Matias Pelenur [mailto:matiasp-nospam-@email.com]
Sent: quarta-feira, 7 de Março de 2001 17:15
To: php-windows@lists.php.net
Subject: Re: [PHP] Problem using readfile
Well, I tried using different code (from a newer message by Mukul
Sabharwal):
header("Content-length: $size");
header("Content-type: $type");
$fp = fopen($actualfile, 'rb') or print('Could not open file!');
$read = fread($fp, $size) or print('Could not read file');
print($read);
and this seems to work better, that is, files are download correctly.
However, there is a strange behavior, at least with IE5, which I don't know
if it's a bug on IE5 or not... When I click on a file, if I choose "save to
disk" it works fine, but if I choose "Open from current location" it
doesn't work. Anyone have any ideas on this?
--Matias
""Matias Pelenur"" <matiasp-nospam-@email.com> wrote in message
news:983od5$oc8$1@toye.p.sourceforge.net...
> Hi,
> I'm trying to use readfile to send a file to the browser. The code I'm
using
> is:
>
> header("Content-length: $size");
> header("Content-type: $type");
> header("Content-disposition: attachment;filename=$filename");
> readfile($filename);
>
> It works fine for very small files, but for larger files it seems to send
> only the first 600 bytes and then hang... I tried with both IE and
Netscape
> and
> have the same problem.
>
> I'm using Apache 1.3.14 and PHP/4.0.4pl1 on Win2000 (using the PHP module
> for Apache)
>
> Any hints appreciated. Thanks!
> --Matias
>
> If you reply via email, please remove the -nospam- from the address.
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>