How to find the path of a specific file?

Discussion in 'PHP' started by Ghe, Jun 11, 2008.

  1. #1
    Good Day to all,

    Ahm, does anyone here know how can i make a function that get the filepath of a specific file?

    I want to create a function like this:
    - getFilePath('A_file_with_an_unknown_path.inc');
    then the function will return the path of the file with an unknown path/directory.

    Is this possible? If not, can anyone tell me how can I be able to include a file with an unknown filepath/directory?

    - require_once('???/???/???/A_file_with_an_unknown_path.inc');

    Please help.

    Thank you in advance.
     
    Ghe, Jun 11, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    You can't do it easily, you need to look in all directories above current for the searching file!
     
    EricBruggema, Jun 11, 2008 IP
  3. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #3
    You could execute the command "locate" by running a shell:
    <?php
    $output = shell_exec('locate ' . $filename);
    echo "<pre>$output</pre>";
    ?>
    This will return all results on the server with the path, but you'd have to parse them to figure out which one you want.
     
    itcn, Jun 12, 2008 IP
  4. Ghe

    Ghe Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ow...i see... thank you very much for this...
     
    Ghe, Jun 12, 2008 IP