PHP Server files browser

Discussion in 'PHP' started by khu84, Jan 4, 2010.

  1. #1
    Do you know any browser that can be added into a page directly to browse files on current server like we do via ftp but the difference is it will be browsing the files of current server where its sitting..

    Should be able to add it in a page and perform custom functions on file.
     
    khu84, Jan 4, 2010 IP
  2. khu84

    khu84 Active Member

    Messages:
    441
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #2
    So, no one have an idea?
     
    khu84, Jan 5, 2010 IP
  3. iAreCow

    iAreCow Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #3
    You can't list all files on the server when on shared hosting, since PHP runs under your account (eg. /home/jim/) and has no right to access other users files (eg. /home/ben/). But you could list all files under your account:
    $dir = scandir("/home/jim/");
    foreach($dir as $file) {
    echo $file; echo "<br>"; }
    PHP:
     
    iAreCow, Jan 5, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    or:

    <?php
    
    //directory path
    $dir = "/home/jim/";
    
    foreach (glob($dir . '*.*') as $file) {
    
    echo $file; 
    echo "<br />";
    
    }
    
    ?>
    PHP:
    But what I think what you'd prefer is something more like this; http://autoindex.sourceforge.net/
    :p
     
    danx10, Jan 5, 2010 IP
  5. khu84

    khu84 Active Member

    Messages:
    441
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Thanks for your replies,

    I didn't actually wanted to list all files, but a specific directory where I have access and all sub structure, I had idea of scandir but I wanted pre-built full functionality file browser.

    But no worries, I have build one myself.

    Will also see auto index for any future use, Thanks.
     
    khu84, Jan 8, 2010 IP
  6. astkboy2008

    astkboy2008 Peon

    Messages:
    211
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    astkboy2008, Jan 9, 2010 IP