Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 01-08-2005, 12:26 PM   #1
michael2002
Confirmed User
 
Join Date: Jan 2003
Posts: 145
php question

what is the best method to test if a file on a remote server (url) exist?

currently i use something like :

Code:
if($x=file($url)) echo("file exist");
else echo("file don't exist");
but this code in the case that the file is not existing take long time to execute

there is any faster method to test if a file on a remote server exist or not?
michael2002 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-08-2005, 12:50 PM   #2
hyper
Confirmed User
 
Join Date: Mar 2002
Location: Mass Ass
Posts: 5,294
PHP Code:
<?php
$file 
fopen ("http://www.example.com/""r");
if (!
$file) {
    echo 
"<p>Unable to open remote file.\n";
    exit;
}
else {
blah blah blah;
}
fclose($file);
?>
__________________
hyper is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-08-2005, 12:51 PM   #3
Clarion
Confirmed User
 
Join Date: Jan 2005
Location: Ontario, OR
Posts: 148
Quote:
Originally Posted by hyper
PHP Code:
<?php
$file 
fopen ("http://www.example.com/""r");
if (!
$file) {
    echo 
"<p>Unable to open remote file.\n";
    exit;
}
else {
blah blah blah;
}
fclose($file);
?>
change the first line to this so you don't generate any errors. $file = @fopen ("http://www.example.com/", "r");
__________________
Structure Northwest :: the cure for the common code ::
AIM: Asatruel | Yahoo!: Asatruel | ICQ: 111-638-053
Clarion is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-08-2005, 12:53 PM   #4
Aric
Confirmed User
 
Aric's Avatar
 
Industry Role:
Join Date: Sep 2002
Posts: 1,209
Don't forget the speed of the remote server is factored in here, not just your checking code.
Aric is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.