FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Searching a web directory





pirate
hey there i need help with something, i don't think it would be too complicated but can you guys help me. Basically i need to make a search form that searches a specified directory and if a file exists it echos out that it exist's

This doesn't involve any search engine stuff like phpmyadmin just a simple directory search. Any Ideas???
sonam
I will do it on this way. Maybe someone have better solution but... You just need to submit via form file name and the rest will do script.


Code:
$findFile = "background.jpg";  // submitted name

$root  = $_SERVER['DOCUMENT_ROOT'];

$openDir  = opendir($root . "/images");
while (FALSE !== ($fileNames = readdir($openDir))) {
        if(is_dir($fileNames) ){
           continue;
        } else {
          $allFiles[] = $fileNames;   
         }
}
if(array_search($allFiles) === FALSE) {
    echo "This file don't exist";
 } else {
    echo "File " . $findFile . " exist.";
 }
?>


Sonam
jmraker
No need to initialize a list of every file in a directory into an array to check if a file exists
http://us3.php.net/file_exists

Code:
<?php
// make sure  $_REQUEST['directory'] ends with the DIRECTORY_SEPERATOR
$find = $_REQUEST['directory'] . $_REQUEST['findFile']; // "images/" . "background.jpg";  // submitted dir + submitted name

if(file_exists($find))
    echo 'This file don\'t exist';
}
else {
    echo 'File ' . $find . ' exists.';
}
exit();
?>
Related topics
CrazyLeaf Design Web Directory and Forum
Free Web Directory
Free Web Directory
web directory
searching web hosting space
Planet Freelance CMS Web Directory
Which is the best PHP Directory Script?
PR 3 Directory - Free Submission post your site here.
Ignite Links Directory - Boost your pagerank for free!
Get Paid 5 FRIH$ per link you submit to a free web directory
Adult web directory
Submit your links to Central Directory
My new Free Web Directory
Free Directory Submission|Fast Apporval
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.