GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   php question (https://gfy.com/showthread.php?t=413796)

michael2002 01-08-2005 12:26 PM

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?

hyper 01-08-2005 12:50 PM

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);
?>


Clarion 01-08-2005 12:51 PM

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");

Aric 01-08-2005 12:53 PM

Don't forget the speed of the remote server is factored in here, not just your checking code.


All times are GMT -7. The time now is 07:40 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123