PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Timeout while waiting for a server->client transfer to start (large files)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Timeout while waiting for a server->client transfer to start (large files)

Réponse
 
LinkBack Outils de la discussion
Vieux 29/01/2008, 18h45   #1
Barney Tramble
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Timeout while waiting for a server->client transfer to start (large files)


Hey

I have a script that I am trying to figure out to allow a remote file to
be sent to a client's browser. It works ok for small files, but it keeps
timing out for large files. I don't think it should even take as long as
it does (i.e. about 10seconds) before it pops up a dialog box for me to
download a 700KB file. Any ideas? It times out on a line around which reads

while (!feof($fp))
{
$tmp .= fread($fp, 64);
}

Thanks
  Réponse avec citation
Vieux 30/01/2008, 07h01   #2
Chris
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Timeout while waiting for a server->client transfer tostart (large files)

Barney Tramble wrote:
>
> Hey
>
> I have a script that I am trying to figure out to allow a remote file to
> be sent to a client's browser. It works ok for small files, but it keeps
> timing out for large files. I don't think it should even take as long as
> it does (i.e. about 10seconds) before it pops up a dialog box for me to
> download a 700KB file. Any ideas? It times out on a line around which reads
>
> while (!feof($fp))
> {
> $tmp .= fread($fp, 64);
> }


Well you're still reading the file (or url or something) at this point.
Is it the reading of the file or sending it to the browser that fails?

A bit of context might for this code too. Is this reading a local
file or url or what?

If it's a local file, use fpassthru (http://php.net/fpassthru) if it's
not too big. If it is a big file then use your loop but don't store it
in a $tmp variable, just output it.

--
Postgresql & php tutorials
http://www.designmagick.com/
  Réponse avec citation
Vieux 31/01/2008, 00h02   #3
Richard Lynch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Timeout while waiting for a server->client transfer tostart (large files)

On Tue, January 29, 2008 12:45 pm, Barney Tramble wrote:
> I have a script that I am trying to figure out to allow a remote file
> to
> be sent to a client's browser. It works ok for small files, but it
> keeps
> timing out for large files. I don't think it should even take as long
> as
> it does (i.e. about 10seconds) before it pops up a dialog box for me
> to
> download a 700KB file. Any ideas? It times out on a line around which
> reads
>
> while (!feof($fp))
> {
> $tmp .= fread($fp, 64);
> }


Your script is reading the whole file, 64 measly bytes at a time, into
a monstrous string $tmp.

Then, finally, when you've loaded the whole [bleep] file into RAM in
$tmp, you just echo it out, right?

Don't do that.

:-)

while (!feof($fp)){
echo fread($fp, 2048);
}

You can play around with 2048 versus 64 versus 1000000 on your box to
see what's "fastest" but I'll be pretty shocked if 64 bytes is the
best performer...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
  Réponse avec citation
Vieux 31/01/2008, 07h13   #4
Per Jessen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Timeout while waiting for a server->client transfer to start (large files)

Richard Lynch wrote:

> Your script is reading the whole file, 64 measly bytes at a time, into
> a monstrous string $tmp.
>
> Then, finally, when you've loaded the whole [bleep] file into RAM in
> $tmp, you just echo it out, right?
>
> Don't do that.
>
> :-)
>
> while (!feof($fp)){
> echo fread($fp, 2048);
> }



And if the OP is opening the file anyway, he might as well use
readfile() instead.


/Per Jessen, Zürich
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h14.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14534 seconds with 12 queries