Webmaster общности: Predpriemach.com | SearchEngines.bg

    PHP – Търсачка за файлове от дадена директория

    Името на файла да е search.php, а директорията в която ще търси е /upload/

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
    <title>Search</title>
    </head>
    
    <body>
    <center>
    <form action="search.php" method="post">
    <input type="text" name="searched">
    <input type="submit" value="search">
    </form>
    
    <?php
    $flag=0;
    $dir="upload/";
    if(isset($_POST['searched'])) {
    foreach(glob($dir."*") as $file) {
    if(@eregi($_POST['searched'], str_replace($dir, "", $file))) {
    echo("<a href='".$file."' target=_blank>".str_replace($dir, "", $file)."</a><br />\n");
    $flag+=1;
    }
    }
    if($flag==false) {
    echo("Няма намерени файлове.");
    }
    }
    ?>
    </center>
    </body>
    
    </html>