What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » [Solved]PHP directory listing

Pages: (2): « First [ 1 ] 2 » Last »
[Solved]PHP directory listing
Author: Message:
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
Status: Online
O.P. [Solved]PHP directory listing
Hello.

How can I list the contents of a directory using PHP?
I would like the newer files to be shown first.

I have searched google and found this: http://webxadmin.free.fr/article/php-dir-list-and-sort-by-date-209.php
However, I cant get it working...

I set it to list the root ( / ) however, all I get is an empty page.


Thanks!

Edit: I forgot to say, that I'm using PHP 5.0.4

This post was edited on 02-13-2006 at 05:48 AM by Mike.
YouTube closed-captions ripper (also allows you to download videos!)
02-11-2006 08:15 AM
Profile E-Mail PM Web Find Quote Report
Dempsey
Scripting Contest Winner
*****

Avatar
http://AdamDempsey.net

Posts: 2395
Reputation: 53
37 / Male / Flag
Joined: Jul 2003
RE: PHP directory listing
Well if its not your server, you probably don't have root access, thats why it doesn't work.  Try listing a folder you have access to and see if that works.
SoundPacks   -   Scripts   -   Skins

that's not a bug, thats an unexpected feature
02-11-2006 08:23 AM
Profile E-Mail PM Web Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
Status: Online
O.P. RE: PHP directory listing
Well, I'm hosted by dt...
However, Im not really sure what directory I should pass to list....
YouTube closed-captions ripper (also allows you to download videos!)
02-11-2006 08:32 AM
Profile E-Mail PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: PHP directory listing
quote:
Originally posted by Mike
Well, I'm hosted by dt...
However, Im not really sure what directory I should pass to list....

if its current directory you want to list its ./ not / :P
02-11-2006 08:34 AM
Profile PM Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
Status: Online
O.P. RE: PHP directory listing
quote:
Originally posted by Eljay
quote:
Originally posted by Mike
Well, I'm hosted by dt...
However, Im not really sure what directory I should pass to list....

if its current directory you want to list its ./ not / :P
Just tried, still empty page :(
YouTube closed-captions ripper (also allows you to download videos!)
02-11-2006 08:35 AM
Profile E-Mail PM Web Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: PHP directory listing
Well, that code alone doesn't output anything... you need to handle that yourself... :p
02-11-2006 08:38 AM
Profile PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: PHP directory listing
quote:
Originally posted by Mike
quote:
Originally posted by Eljay
quote:
Originally posted by Mike
Well, I'm hosted by dt...
However, Im not really sure what directory I should pass to list....

if its current directory you want to list its ./ not / :P
Just tried, still empty page :(

tried print_r($Files); ¬¬

that code is just to get the array

edit: WDZ :(

This post was edited on 02-11-2006 at 08:38 AM by Eljay.
02-11-2006 08:38 AM
Profile PM Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
31 / Male / Flag
Joined: Mar 2003
Status: Online
O.P. RE: PHP directory listing
Now i get an output, but it looks weird :P
Something like this:
quote:
Array ( [0] => Array ( [0] => ./mediaplayer.php [1] => 1137315439 )

I guess I will have to loop through the arrays and echo(); them?

This post was edited on 02-11-2006 at 08:42 AM by Mike.
YouTube closed-captions ripper (also allows you to download videos!)
02-11-2006 08:40 AM
Profile E-Mail PM Web Find Quote Report
Eljay
Elite Member
*****

Avatar
:O

Posts: 2949
Reputation: 77
– / Male / –
Joined: May 2004
RE: PHP directory listing
quote:
Originally posted by Mike
Now i get an output, but it looks weird :P
Something like this:


I guess I will have to loop through the arrays and echo(); them?

yes
02-11-2006 08:43 AM
Profile PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: PHP directory listing
Some example code...
code:
echo "<ul>\r\n";
foreach($Files as $file) {
    $file_path = $file[0];
    $file_name = basename($file_path);
    $last_modified = $file[1];
    $last_modified_str = date('Y-m-d H:i:s', $last_modified);
    echo "<li>$last_modified_str $file_name</li>\r\n";
}
echo "</ul>";
:spam:
02-11-2006 08:49 AM
Profile PM Web Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On