Posted by Richard Lynch on 01/19/05 18:54
Sephiroth wrote:
> Hi all,
>
> How to access remote files with php?
> For ex:
> $sFile = "http://www.php.net/123.txt";
> if (file_exists($sFile)) {
> $hFile = fopen($sFile);
> ...
> fclose($hFile);
> }
At the risk of being accused of copying whatshisname...
"Yes."
:-)
You're pretty much written the code in its most simple form the way it
should be, and it should work as-is.
You'd want to add in some error-checking code so your application does
something reasonable when the file isn't found, or the network connection
flakes out, or...
PS file_exists() may only work for URLs in recent versions of PHP... Read
the manual to find out which versions.
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|