Checking if a file exists --> Distant files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Meriouma
Forum Newbie
Posts: 1
Joined: Fri Apr 11, 2003 6:52 pm

Checking if a file exists --> Distant files

Post by Meriouma »

Hi,

Anyone know if there's a way to know if a file exist on a distant server?

thanks
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Code: Select all

<?php
echo readfile($FILE_LOCATION) or die("Unable to find file.");
?>
Image Image
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

readfile() will print the content of the file. Maybe fopen() is sufficient.
If url_wrappers are disabled you might use php's ftp-functions or open a socket (if available) to send a http-request and check the response code.
Post Reply