Page 1 of 1
Remote fopen fails...
Posted: Thu Jun 09, 2005 6:04 pm
by Todd_Z
Code: Select all
$hnd = fopen( "http://www.alexa.com", "rb" );
yields
Code: Select all
ї09-Jun-2005 16:58:29] PHP Warning: fopen(http://www.alexa.com): failed to open stream: Connection refused in **********************/test.php on line 7
ї09-Jun-2005 16:58:29] PHP Warning: fread(): supplied argument is not a valid stream resource in ***********************/test.php on line 9
an ini_get_all() shows me:
Code: Select all
їallow_url_fopen] => Array
(
їglobal_value] => 1
їlocal_value] => 1
їaccess] => 4
)
Any idea why this is? *fsockopen fails too*
Posted: Thu Jun 09, 2005 11:47 pm
by anjanesh
Works here
Code: Select all
<?php
$hnd = fopen("http://www.alexa.com", "rb");
$contents = '';
while (!feof($hnd)) {
$contents .= fread($hnd, 8192);
}
echo $contents;
fclose($hnd);
?>
Posted: Thu Jun 09, 2005 11:59 pm
by Todd_Z
Theres something screwed up with my server, I know my code is correct.
Posted: Fri Jun 10, 2005 2:14 am
by Syranide
If it isn't your server outbound connections might have been blocked.
Posted: Fri Jun 10, 2005 3:35 am
by malcolmboston
anjanesh wrote:Works here
Code: Select all
<?php
$hnd = fopen("http://www.alexa.com", "rb");
$contents = '';
while (!feof($hnd)) {
$contents .= fread($hnd, 8192);
}
echo $contents;
fclose($hnd);
?>
i tried a code practically identical yesterday as a test for my EzThumb class, as i have to seperate ways of reading local and remote files, this code basically just created an infinite loop.
I have also seen this code recommended in the PHP manual, som im not sure why it wont work for some people
Posted: Fri Jun 10, 2005 1:47 pm
by Todd_Z
How are outbound connections blocked, and how do i lift this block?