Khalid El-Kary wrote:
> hi,
> i want to open a remote file using fopen() i tried both of these ways
> 
> $filename="http://www.domain.com/filename.txt";;
> $file=fopen($filename,"r");
> $filecontents=fread($file,filesize($filename));
> 
> this one didn't work because it's apparent that the file isn't in the
> local file system so filesize($filename) won't work ...
> 
> the second way was this:
> 
> $filename="http://www.domain.com/filename.txt";;
> $file=fopen($filename,"r");
> $filecontents="";
> while (!feof($file))
> {
>   $filecontents.=fgets($file);
> }
> 
> this one worked well with PHP4.2.3 but with versions under PHP 4.2.0
> it didn't work
> 
> So what else can i try to just get the whole contents of the file
> into a string?

$filename = http://www.domain.com/filename.txt;
$fp = fopen($filename,"r");
while (!feof($file))
   $content .= fread($fp,4096);


HTH
Erwin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to