Files and Directories
|
|
|
|
<?php function doiexist($path, $findfile)
{ // Source = www.spiderandjenni.com/phptips $found=0;
if ($dir = @opendir($path)) {
while (($file = readdir($dir)) !== false) {
if($file==$findfile){$found=1;}
}
closedir($dir);
}else{print "no such dir path"; $found==2;}
return($found);
}
?> ?>
|
|
|
Usage Example
|
$findfile1="logo.jpg";
$finddir="logos";
if(doiexist($finddir, $findfile1))
{
print <IMG SRC='$finddir/$findfile1'>";
}
else
{
print "the image file is not on the server yet!";
}
|
|
|
Rate This Script
|
|
|
|