I have a script that downloads a sequence of files online. Every hundred
files or so, it fails with:
==
Warning: file_get_contents(URL) []: failed to open stream: A connection
attempt failed because the connected party did not properly respond after a
period of time,
Marshall Burns wrote:
I have a script that downloads a sequence of files online. Every hundred
files or so, it fails with:
Check for the return value being equal to false:
?php
if( ($sFil = file_get_contents( $sURL )) === false )
{
// FAIL
}
else
{
//
Robert Cummings wrote:
Marshall Burns wrote:
I have a script that downloads a sequence of files online. Every hundred
files or so, it fails with:
Check for the return value being equal to false:
?php
if( ($sFil = file_get_contents( $sURL )) === false )
{
// FAIL
=125622597723923w=2 .
Thanks.
-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com]
Sent: Thursday, October 22, 2009 08:44
To: Marshall Burns
Cc: php-general@lists.php.net
Subject: Re: [PHP] Trapping failure of file_get_contents()
Marshall Burns wrote:
I have a script
Marshall Burns wrote:
Robert and others,
I made that change in the code. It still does not trap the failure. I
believe the reason is that the script is timing out while
file_get_contents() is sitting there waiting for input. The problem is that
the function never returns, so there is no return
Hi Marshall,
the function file_get_contents may have problem with large files.
You could try get the file using fread and feof.
Here i put a example
$contents = '';
while(!feof($stream)){
$contents .= fread($stream, 8192);
}
Gerardo Benitez.
On Thu, Oct 22, 2009 at 12:38 PM,
6 matches
Mail list logo