Important alert: (current site time 7/15/2013 10:24:08 AM EDT)
 

VB icon

A file indexer / lister

Email
Submitted on: 10/5/2002 9:55:37 AM
By: gmtt_dan  
Level: Beginner
User Rating: By 3 Users
Compatibility: PHP 3.0, PHP 4.0
Views: 22713
(About the author)
 
     this list alls the files in a the current directory
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: A file indexer / lister
// Description:this list alls the files in a the current directory
// By: gmtt_dan
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=765&lngWId=8//for details.//**************************************

<? $maindir = "." ; $mydir = opendir($maindir) ; $exclude = array( "index.php") ; while($fn = readdir($mydir)) { if ($fn == $exclude[0] || $fn == $exclude[1]) continue; echo "<br><a href='$fn'>$fn</a>"; } closedir($mydir); ?>


Other 12 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
4/27/2003 9:27:25 PMTechni Rei Myoko

for gods sake
seperate your lines
(If this comment was disrespectful, please report it.)

 
4/27/2003 9:35:03 PMTechni Rei Myoko

and it should be
(If this comment was disrespectful, please report it.)

 
6/7/2003 4:32:03 AMHell_Freezer

yeah i know, but i just copied it directly out of my code, so......i didn't bother, though yes your right, my lines should be seperated. ah well.
(If this comment was disrespectful, please report it.)

 
7/11/2003 11:24:00 PM

nice little script, i added some checking for file types and some javascript to it and now it displays all jpgs gifs and pngs in a folder and when a person clicks on it it puts it in a fild in the form. thanks a buncho
(If this comment was disrespectful, please report it.)

 
7/12/2003 5:55:33 AMHell_Freezer

:) thank you for writing some feedback
(If this comment was disrespectful, please report it.)

 
7/29/2003 1:40:39 PMDaniel Smith

Thanks, this is just what I needed, nice and simple. :)
BTW, it doesn't work right away... it expects two array items in that if statement, so you have to add one for it to work, or change the statement...
(If this comment was disrespectful, please report it.)

 
12/14/2003 4:19:42 AMDavid A. Edwards

Very nice, simple code. I removed the $fn == $exclude[1] section and changed the exclude to ls.php This code has helped me in the past also, on an uploader
(If this comment was disrespectful, please report it.)

 
12/19/2003 2:56:29 PMPeter van Velzen

here the code with seperated lines :D <@ href='$fn'>$fn"; } closedir($mydir); ?>
(If this comment was disrespectful, please report it.)

 
3/21/2004 10:06:47 AMDamic

Great code Splitted as well :) <@ href='$fn'>$fn"; } closedir($mydir); //replace @ with A ?>
(If this comment was disrespectful, please report it.)

 
7/21/2004 1:25:37 AM

like the code, simple yet efective
thanks for this.
(If this comment was disrespectful, please report it.)

 
8/25/2004 8:08:58 PM

Hi. Great code but how can I list the file and the filesize from the directory and not only the filename? I've tried the $fn($filename) but it doesn't work!
(If this comment was disrespectful, please report it.)

 
8/25/2004 8:10:55 PM

sorry I ment the $size not the $filename ;)
(If this comment was disrespectful, please report it.)

 
8/25/2004 10:23:07 PMShatners

Download my updated version from http://www.gmtt.co.uk/free2.php

See the demo: http://www.gmtt.co.uk/directory.php
(If this comment was disrespectful, please report it.)

 
12/12/2004 3:15:14 PMJohn Avison

why the hell did you not tell anyone that this code was origannaly posted by someone else on pscode and the data that this was posted is LATER than the other date....
(If this comment was disrespectful, please report it.)

 
4/30/2005 4:13:51 PMwww.loveboard.tk

very nice

it helped me here www.vexat.net

thanx :-)
(If this comment was disrespectful, please report it.)

 
6/5/2005 12:37:05 PMDanny Pryor

<@@ href='$fn'>$fn"; } closedir($mydir); //replace @@ with //A ?>
(If this comment was disrespectful, please report it.)

 
6/5/2005 12:39:56 PMDanny Pryor

ohh gods sake....... someone give us a freakin parsing tutorial for p.s.c. ... nothing ever displays properly....notepad use to work , now it doesnt..... tell us IAN , how the heck we should post text on here properly formatted ?
(If this comment was disrespectful, please report it.)

 
11/25/2005 4:53:30 PMOkan

I want list files by create date.How can i do this help me plz :(
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.