Do you have a question? Post it now! No Registration Necessary. Now with pictures!
September 20, 2004, 2:57 pm
rate this thread
Permissions have been set to 755.
Do I have to open the file first?
Then read it?
echo "File name = ".$filename; This echoes the correct name and path.
$fileopen = fopen($filename, "rb");
echo "File open = ".$fileopen; This echoes Resource id #4
What is resource id #4?
Where do I find a definition of resource id #4?
$contents = fread($fileopen, filesize($fileopen));
echo "File size = ".filesize($filename); This echo is empty.
echo "Contents = ".$contents; This echo is empty.
AFAIK you can't request the filesize of a remote file (perhaps in PHP
Try something like this:
$strText = '';
$fh = fopen( $strURL, 'r') or die( $php_errormsg );
while( !feof( $fh ) )
$strText .= fread( $fh, 1024 );
fclose( $fh );
header( 'Content-type: text/plain' );
fopen() returns an ID that denotes the currently opened file. It's a
handle for all further actions performed on that file.
Resource-IDs are a special type in PHP.
You can't use filesize() on remote files in PHP4.
This should be
You could also try this simple code instead:
$filename = 'http://...';
$content = file_get_contents($filename);