Re: Fastest way to read from an url?

From: Date: Wed, 23 Jan 2002 15:44:56 +0000
Subject: Re: Fastest way to read from an url?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-81696@lists.php.net to get a copy of this message
> * and then Stefan Rusterholz blurted.... > > Wenn I open the URL with the Browser (with "save link to disk") I get an approximatly speed of 1MB/s (it's on an intranet) but doing the same with PHP, PHP only reaches speeds about 200KB/s. > > Do you *have* to use php? > What is it and what's the story? Yes, I *have* to use php. It's an automation of downloading images, pdf's, excel sheets and so on (just binary data, as I told) from an intranet-webserver onto the extranet-webserver. The script has to work under *nix and w2k. To tell you the whole story I think is unecessary and would get me tired of typing. Please just accept, that php *has* to do the work and that there is no way to change the environment. To set up a scheduled script copying the stuff is also *not* a solution. TIA & best regards Stefan Rusterholz ---original message--- I got following problem: I have to open an url (with PHP of course) and read it's content into a variable. The URL contains binary data from about 1MB to 5MB. Wenn I open the URL with the Browser (with "save link to disk") I get an approximatly speed of 1MB/s (it's on an intranet) but doing the same with PHP, PHP only reaches speeds about 200KB/s. I use following construct: $filecontent = ""; if (!$fc = fopen('http://remotehost/'.$filepath,'b')){ trigger_error("fopen failed on ".'http://remotehost/'.$filepath, E_USER_ERROR); } while (!feof ($fc)) { $buffer = fread($fc, $chunk_size); $filecontent .= $buffer; } fclose ($fc); $chunk_size is set to 16*1024 (=>16Kb) I experimented a bit with the chunksize and at this size it seems to be at its fastest, but still 5 times slower than it should be possible. How can I gain max. speed?

« previous php.general (#81696) next »