Go Back   Web Master'S Zone > Web Design > Tutorials / Resources

Tutorials / Resources Tutorialize others and yourself with these useful how-to-do's and what-not-to-do's.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-03-2008, 08:15 PM
Crown's Avatar
Moderator
 
Join Date: May 2008
Location: UK, Devon
Posts: 71
Rep Power: 8
Crown is on a distinguished road
Send a message via MSN to Crown
Default [PHP]List Files in Dir..

This Script Allows you to view whats in a directory.
First..
Create a file called 'dir.php'
Secondly
Paste this code in the file..
PHP Code:
<?php
// open this directory 
$myDirectory opendir(".");

// get each entry
while($entryName readdir($myDirectory)) {
    
$dirArray[] = $entryName;
}

// close directory
closedir($myDirectory);

//    count elements in array
$indexCount    count($dirArray);
Print (
"$indexCount files<br>\n");

// sort 'em
sort($dirArray);

// print 'em
print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n");
print(
"<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR>\n");
// loop through the array of files and print them all
for($index=0$index $indexCount$index++) {
        if (
substr("$dirArray[$index]"01) != "."){ // don't list hidden files
        
print("<TR><TD><a href=\"$dirArray[$index]\">$dirArray[$index]</a></td>");
        print(
"<td>");
        print(
filetype($dirArray[$index]));
        print(
"</td>");
        print(
"<td>");
        print(
filesize($dirArray[$index]));
        print(
"</td>");
        print(
"</TR>\n");
    }
}
print(
"</TABLE>\n");

?>
3rdly
Upload to web server then visit 'http://www.yourdomain.com/dir.php/
Thats it, Useful i dont know
Thanks
Reply With Quote
  #2 (permalink)  
Old 06-03-2008, 08:26 PM
Ehsan's Avatar
Administrator
 
Join Date: May 2008
Location: Pakistan
Posts: 136
Rep Power: 9
Ehsan will become famous soon enoughEhsan will become famous soon enough
Send a message via MSN to Ehsan Send a message via Yahoo to Ehsan Send a message via Skype™ to Ehsan View Ehsan's Twitter Profile
Default

This is pretty cool just tried t on one of my sites but i am not sure what it could be used for lol
__________________
Reply With Quote
  #3 (permalink)  
Old 06-03-2008, 08:32 PM
Crown's Avatar
Moderator
 
Join Date: May 2008
Location: UK, Devon
Posts: 71
Rep Power: 8
Crown is on a distinguished road
Send a message via MSN to Crown
Default

Well i did say Useful i dont know lol :P
you could list like umm Files on your server probs that pretty neat ^^
Reply With Quote
  #4 (permalink)  
Old 06-04-2008, 11:34 PM
IamShipon1988's Avatar
Administrator
 
Join Date: May 2008
Location: Rochester, NY
Age: 23
Posts: 103
Rep Power: 0
IamShipon1988 is an unknown quantity at this point
Send a message via AIM to IamShipon1988 Send a message via MSN to IamShipon1988 Send a message via Yahoo to IamShipon1988 Send a message via Skype™ to IamShipon1988
Default

Personally I like Celerondudes version (DEMO) better. I will work with this php code to make a better one if thats okay with you. For anyone thats looking for a demo, well here it is: http://sazzadhossain.org/portfolio/dir.php
__________________
Sazzad Hossain
"Let it be and move on. If it comes back, kick it in the back and move on. It it happens again, take down the IE server."
Sazzad Hossain | EasyLyrics | Hip-Hop Clique | Jorsek Softwares
Reply With Quote
  #5 (permalink)  
Old 06-05-2008, 02:19 PM
Crown's Avatar
Moderator
 
Join Date: May 2008
Location: UK, Devon
Posts: 71
Rep Power: 8
Crown is on a distinguished road
Send a message via MSN to Crown
Default

Hey Sazzad, Thats fine do as you wish
I like the one your useing now
Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OS]List files in a Dir via .bat file.. Crown Tutorials / Resources 0 06-03-2008 08:22 PM


All times are GMT. The time now is 01:33 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.