PHP Directory Listing Script
Back in 2008 we released the original version of this directory listing script, this is the updated version which resolves a number of known issues with the previous version.
The PHP Directory Listing Script is a highly configurable script which generates a well formed table, listing the contents of a specified directory and sub-directories. The script displays images for certain file types with the ability to generate thumbnails to preview image files.
The PHP Directory Listing Script requires PHP, Javascript and GD2 for thumbnail generation.
Please click here to see a demonstration of the PHP Directory Listing Script.
Download
To download the script please click here. The ZIP file contains all you need to run the script. To setup the script please see the top of index.php.
Future
Please leave any feature requests or questions in the comments below, we will incorporate features as appropriate and answer questions where possible.
Tags: directory listing, php, script


172 Comments
Patrick
February 17, 2011 at 11:50 amFirst: Thanks for sharing this great Script. It save a lot of work.
But i have some Bugs, when i did implemented the script in my site. Only if i set the path to “.” i can go to the subdirectories. If i set it to a subdir, than i can see the content, but then i cant go down in other subdir’s. And if I want to download the files via forcedownload, i get a lot of various characters, but no download popup.
The demo works fine..but i dont know why it doesnt work anymore when i implemented it via include. I hope you can help me.
Ash
February 17, 2011 at 12:26 pmThanks for the comment Patrick, we’ll take a look at the bugs and get a new version posted ASAP.
Patrick
February 17, 2011 at 12:45 pmOkay, thanks. Maybe the include solution is the reason why i cant set the standard subdirectory…i dont know. The demo works fine.
lolo
February 25, 2011 at 4:28 pmThanks much! Very usefull script!
I’ll be happy to get that correction concerning the subdirectories problem
Matt
April 13, 2011 at 6:58 pmHey, thanks for the nice script. I could definitely use the solution to the sub directories problem as well. Cheers…
James Thomas
April 14, 2011 at 2:40 pmHi Patrick,
For people wishing to include the file in their script, we have added an $includeurl; variable for you to add the actual URL of the script in your site; take a read the comments in the new zip file! As for the the download problem you were having, try again with the new script.
Matt Cram
April 16, 2011 at 12:04 amThanks to Ash, James, and team for the V3 update…
Dmitry Garanin
May 17, 2011 at 6:41 pmI know this directory lister for a couple of years and now I planned its more extensive use at http://lokshin.org/Scores/ .
Unfortunately, the output is broken, although filenames are OK.
Also there is no simple customization. Changing the style file is difficult, especially that my web server has a big latency and does not immediately show results of my experiments. I remember with some version of changed style file the output was not broken but the sizes were distorted.
If it remains like this, I will have to delete the style file and have a raw output, that will also do the job.
A comparable free file lister that I have found is bobbsfilelist. It works but is not customizable and uses while text on a black background that I don’t like.
Aldo
June 29, 2012 at 9:48 amLove the available features. And spanks everything else I’ve found that’s free.
For some reason though I can’t get it to work on files larger than about 4Mb…even on files that I’ve confirmed work. PHP.ini is set to 40Mb so that’s not it.
It shows loading progress to 100%, then waits for the website, refreshes, and nothing happens. No error messages and no new file in the directory. Just looks like nothing happened. Ideas?
Tomas
February 18, 2011 at 10:59 pmThis is really a GREAT WORK!!! You saved my *ss! Thanks a lot! Everything works fine, even that “subdir browsing” Patrick talked about. Thanks again!
CaliVW78
February 20, 2011 at 4:19 pmFirst off, where do I donate? This was extremely useful, and much appreciated.
Secondly, is there any example of how I could paginate this? Some directories have tens of thousands of files, which can be an issue for those with older machines with less horse power.
Thanks again!
Ash
March 04, 2011 at 8:12 amThanks for the comment, no donation is required!
We’re looking at pagination for a future release.
Mister Smith
February 25, 2011 at 8:10 amLooks really great, but doesnt fit for me because this script isnt able to handle large filenames…
if it could, it would be my absolute favorite dirlister
Ash Young
March 04, 2011 at 8:16 amDo you have an example of where you’ve tried to use the script with longer filenames?
peter
March 07, 2011 at 11:21 amWhen the filename is to long to fit into one line, weird things happen. E.g. the icons of the files show up in the middle of the previous row.
Another bug: the script cant handle UTF8-filenames yet. The links work, but the non-american characters in the names are shown wrong.
Regards,
Peter.
Don McKenzie
July 10, 2011 at 9:50 pmDoes everything I need, as I have set mine up as a public deposit and viewer for a special interest user group,
I have got the contributors to include the following:
YYYY-MM-DD-firstname-lastname-filename-Version.zip
So that the file explains itself, however if you expanded the width to cater for about another 16 characters, it would be perfect.
I tried, but there is too many setting for me to tackle. Found the filename shorten-er, and adjusted that a little.
Thanks in advance,
Cheers Don…
Edgar
February 27, 2011 at 3:22 pmSEO friendly urls would be very nice. Right now the output looks very scary.
tygrysalex
March 24, 2011 at 8:30 amSEO friendly urls + pagination = THE BEST Directory Listing Script
Please, do it for humanity
yinka
March 05, 2011 at 7:39 pmThis is the best free PHP directory script so far.
akhtar
March 07, 2011 at 9:51 amHi,
is there any way i can see the preview without going inside the director.
i would like to preview the images from outside the image with the mouse right click.
thanks
satwik
March 09, 2011 at 5:33 amHi
I am already using your script for directory listing which is great. I have got more than 200 files now and is it possible to add any search function on the page? Has it been in effect yet? I will appriciate your reply.
Artax
May 18, 2011 at 2:39 pmSimply hit Ctrl+F and you’ll get a nifty search box.
Eric
March 10, 2011 at 7:43 amI’m LOVING the script. However, I need to figure something out.
I have multiple directories I want to list files from, but I can’t figure out how to code it.
Basically, I have the script in its root folder. Underneath that I have separate users who each have a mod folder.
I need the script to display the mod folders of EACH user.
For example: it’s currently showing /0figment0/mods (The true path is mcmodders/0figment0/mods)
But I also need it to display the contents of /ikeelyou/mods and later on more users as well.
How would I code that?
Eric
March 11, 2011 at 5:24 amNo ideas?
Ukyo
March 10, 2011 at 6:03 pmNice script!
I second the “pagination” motion, it’d be nice for directories with a big number of files.
Adam
March 11, 2011 at 2:19 pmThis works just great!
Thanks for sharing
JT
March 11, 2011 at 4:17 pmWould love to have an option in the config area to disable the “Last Modified” and only show file name and size. (My site uses many long file names) In addition, having a version that is more mobile phone friendly (for Android preferably) would be great.
Thanks for the fantastic script!
Scott
March 15, 2011 at 10:45 amHello, I was wondering if there was an alternate .css file for the directory listing script that would make the table wider, especially where the file name shows up. Also, seems like with wide screen browsers might be better to make it wider in general Basically I’ve got some long file names and they are getting cut off.
Also, is there a way to make the file names not be the bold font in the listing?
Super script over all, just trying to figure out how to best tweak it to fit my needs. Thanks!
armin
March 19, 2011 at 11:05 pmWoow, Very Nice script. That was very useful. Thanks
php4pro
March 21, 2011 at 3:46 pmthere is a problem if i put folder path instead of ‘.’ it’s working but the sub folder contents not appear?
Thank you
James Thomas
April 14, 2011 at 2:10 pmHi there,
This issue has been addressed; setting a path in $startdir should no longer prevent files from displaying.
Dinaker
March 22, 2011 at 5:25 amHello,
I have downloaded and installed the code and it’s working fine. But the index.php file has an upload form and I don’t see any upload option to upload files to the directory on my website. Please help.
Dan T
April 14, 2011 at 6:51 pmTo enable uploads, just activate the one variable:
$allowuploads = true;
(file size is up to 8 megs)
Linda
March 22, 2011 at 3:51 pmI really like your script. Is there a way to get it to expand to show the files listed in the directory without having to click on the directory?
Also can I use this script for a commercial application?
Dan Eliot
March 23, 2011 at 5:23 pmLOVE this script. The only issue we’ve had is that really LARGE FILES for download don’t seem to work well with the script. To be fair, however, that may be PHP and our provider, and not the script. Anybody use this script on DREAMHOST with large (100meg+) files?
Dan Eliot
March 23, 2011 at 5:24 pmAlso… is this V2 or V3? The ZIP says V3, but the comments in the script say V2??
James Thomas
April 14, 2011 at 2:12 pmHello Dan,
The comments in the code have been updated accordingly.
Ratio
March 25, 2011 at 3:55 pmHey,
is there a way to integrate a search button to search for files.
And, i only want to display rar files.
Also a way?
regards
Mads
April 02, 2011 at 2:22 pmHey ThinkTank
In my directory listen, the preview of big images does not show.
How can i make my big images have the preview funktion?
Ect, tjek this site:
http://madsschou.com/Brian%20Gjerstrup/
James Thomas
April 14, 2011 at 2:15 pmHi Mads,
This issue was due to the fact that your PHP setup did not assign enough memory for larger files to be converted. We have therefore added a $memorylimit variable to the configuration section, so you can assign more memory if you need it!
schiho
April 04, 2011 at 1:42 amHi, i would like to know if you can run this script locally when setting the www path under php.ini to C:\outputs\
thanks!
Cris
April 05, 2011 at 12:08 amSorry for my English. I’m using Google translator.
Excellent script!!!
Ash, It can be used for ftp?
What should change?
Thanks
Italic Remover
April 05, 2011 at 8:00 pmCan the italic be removed from file sizes? I can’t seem to find the code for it in the files.
Cizzz
October 27, 2011 at 1:01 pmAdd font-style:normal in CSS #listing a em
sacha
April 05, 2011 at 9:23 pmThis script is really good.
I’ve a bug, files larger than 2go appears in the list but with size at 0kb, and impossible to download.
How to fix it ????
Thanks in advance !
arifwicaksono
April 07, 2011 at 2:58 amvery nice script, but i found it strange because i see upload code in it, but i see nothing about upload file.
how do i upload a file ?
James Thomas
April 27, 2011 at 2:22 pmHi there,
To upload files, set the “$allowuploads” flag to “true”. This will place a file upload form on to the page which will upload files to the current directory.
Rob
April 07, 2011 at 10:41 amHi. Nice work on this.
I seem to behaving with the upload functionality, I’ve set it to true but nothing seems to get uploaded to the site, any other problems had with this?
Thanks
James Thomas
April 27, 2011 at 2:37 pmHi Rob,
Be sure to check the permissions on the folder you’re trying to upload to. If the folder is not write-enabled then the files will not be uploaded.
Christian
April 11, 2011 at 11:19 amHI,
Great Script
i ran it on an Windows IIS.
Everything works fine, but Upload is not possible.
Other upload scripts work proper. I don´t found the issue.
Can someone give me an hint to find it out?
Regards Christian
Jai Gopal Kumar
April 11, 2011 at 4:34 pmI want to make online directory. But there are few problems. First I don’t know which software or which version should I install on my computer because there are lots of php scripts. That is making confusion for me.
Pierre
April 14, 2011 at 7:56 amHi. AMAZING script! Thanks a million. Is there a way of sorting the files by Most Recent date though? I did look at the “asc” and “desc”, but after switching between those, nothing happened still.. please help. thanks.
Cbr
April 15, 2011 at 4:54 pmWorks like a charm ! Thank you
Have also tried to work it out. Anyone solved this or has any idea ?
Pierre
April 14, 2011 at 8:03 amOoh and is there a way of specifying only certain filenames to be displayed in one directory, although there’s a few?
Eg. directory DOC/ has 10 files starting with CHA??.pdf and 4 starting with DAN??.pdf. Can I put ^DAN..\.pdf$ down somewhere to only display the 4 DAN files?
Mike
April 15, 2011 at 12:30 amThis is a great script! It saved me hours of doing this directory listing by hand!
Eric
April 16, 2011 at 11:20 amI never did see an answer to my question regarding this script. I’ll re-post here. I’m hoping someone else is wondering this too
I’m LOVING the script. However, I need to figure something out.
I have multiple directories I want to list files from, but I can’t figure out how to code it.
Basically, I have the script in its root folder. Underneath that I have separate users who each have a mod folder.
I need the script to display the mod folders of EACH user.
For example: it’s currently showing /0figment0/mods (The true path is mcmodders/0figment0/mods)
But I also need it to display the contents of /ikeelyou/mods and later on more users as well.
How would I code that?
Ratio
April 22, 2011 at 7:52 amI only wnat to Display .rar or .zip files.
A way through this???
James Thomas
April 27, 2011 at 12:28 pmHello Ratio,
We’ve added a new array called “$showtypes” which will only allow speficied file types to be displayed.
Dedeniz
April 25, 2011 at 10:41 amGreat work, thanks so much
b0y
April 27, 2011 at 8:59 amhi bro… thanks for your’e script….
it’s realy great code…
i want ask. how if i’m set $allowuploads = false; became “true”. so all people can upload all type off file on server.
and i want ask. how if i want limit file type for upload.
like as i just want user can upload type .jpg only.
thanks brother
James Thomas
April 27, 2011 at 12:26 pmHi there,
Yes, setting the $allowuploads flag to “true” will allow the user to upload files in to the directory they’re currently viewing, so long as that directory can have files written to it.
We’ve set up a new array, “$uploadtypes” which specifies what types of file the user can upload.
b0y
April 27, 2011 at 2:30 pmhi bro thanks for your attention

where i can place new array “$uploadtypes” cos in dirlistingv3 i can’t see this array function and command to call
thanks for your’e attention my bro
James Thomas
April 27, 2011 at 3:08 pmHi again,
Take a look at line 113 in the updated index.php – this is the array you’ll need. It’s currently commented out. Uncomment the array and enter the filename extensions you need; a few should already be in there as an example to get you started!
b0y
April 27, 2011 at 11:02 pmhi bro…
i can’t see you’re command in lin 113. sorry my it’s my eye wrong or i’m really can’t see that.
this my screenshot index.php
dumbcrooks.com/dirlis.JPG
correct me if i wrong.
and i’m download last script in you’re site
http://www.evoluted.net/thinktank/wp-content/uploads/2011/02/dirlistingv3.zip
thanks my bro
James Thomas
April 28, 2011 at 8:29 amHello again!
From the looks of your screenshot you’re getting an older version of the script so please try downloading again. If you still get the version without the $uploadtypes array, clear your browser cache and try again.
b0y
April 28, 2011 at 9:49 amhello again my bro
yes if i’m download old version so where i’m can get new version for this script??
because in this page post, im just see this link download
http://www.evoluted.net/thinktank/wp-content/uploads/2011/02/dirlistingv3.zip
so where i can get new version for this script
thanks my bro
Ash Young
April 28, 2011 at 5:09 pmThe link above has been updated with a new ZIP file containing the updated PHP.
b0y
May 02, 2011 at 4:29 amhi bro
thanks bro…it’s now really new version for listing script. 
D
thanks bro
b0y
April 27, 2011 at 2:51 pmhi bro thanks for your attention
where i can place new array “$uploadtypes” cos in dirlistingv3 i can’t see this array function and command to call
thanks for your’e attention my bro
Eric
April 27, 2011 at 8:15 pmStill now answer to my question?
I’d like the script to show the files in multiple directories while still giving people access to only their directories.
So basically, ModA goes to website.com/Moda/upload and uploads their files. ModB goes to Website.com/MobB/upload and uploads his files.
Users go to website.com/modfiles and see a listing of what’s in Moda and modb’s upload folder.
James Thomas
April 28, 2011 at 8:26 amHi Eric,
Unfortunately this is not a feature we’re planning to add at this time.
Dungeon
August 27, 2011 at 10:04 pmWhat you require involves some Alias settings in Apache or using symbolic links to make directories appear under a different structure.
It *is* possible to do in this script, but that will involve creating an authentication system (or interfacing it to one) which is outside the scope of this script.
There are many content management systems with plugins that do what you require. This is simply a directory/file display script.
b0y
April 28, 2011 at 4:53 pmhello again my bro
if i’m download old version so where i’m can get new version for this script??
because in this page post, im just see this link download
http://www.evoluted.net/thinktank/wp-content/uploads/2011/02/dirlistingv3.zip
but James Thomas says this old version.
so where i can get new version for this script with $uploadtypes array.
thanks my bro
Thankful!
May 22, 2011 at 2:38 amThis is exactly what I needed.
I have a question though, do you have any advice on how I would go about having the images display as a gallery?
Say, lightbox integration, for example?
Dmitry Garanin
May 22, 2011 at 1:50 pmThe listing is broken on my site http://www.lokshin.org/Scores/
Daedalus
May 31, 2011 at 1:58 pmThe script really rocks -have been using it for years. A feature I’m missing is the ability to create folders. That would rock! Keep up the great work! Thanks!
Daniel
November 11, 2011 at 3:55 pmI think exactly the same!
ridhoyp
June 07, 2011 at 8:27 amAwesome! thank you so much…
Mario Fetka
June 17, 2011 at 7:50 pmthx for the update to your great script.
one thing that always frustrated me a little is the missing support for symlinks.
thx Mario
User
June 20, 2011 at 10:03 amThank you. This has been very helpful to me
tismon
June 21, 2011 at 8:26 amthanks a lot dude..
tanveer
June 21, 2011 at 10:06 amnice web site
i really like it
hikarin
June 25, 2011 at 12:55 amThanks, nice script
blepblaad
June 25, 2011 at 11:35 amNice script. Thanks.
The script misplaces the folder icon when a foldername is long.
Matt
June 27, 2011 at 9:29 amAbsolutely fabulous little script!!! I wrote something similar years ago to help sort out image files in directories. This is far better than what I came up with.
Cagsun
July 05, 2011 at 8:35 pmGreat script thank you so much. Saved me a lot of time
Mike
July 06, 2011 at 8:39 pmvery nice…… thanks
Darren
July 08, 2011 at 2:08 amHi,
How would I go about putting a working delete button next to each file listed?
Benjamin Flesch
July 09, 2011 at 12:04 pmHello Ash,
the PHP Directory Listing Script contains a XSS security flaw which renders all installations of your software vulnerable to XSS attacks. I have published a patch and some information about this vulnerability here:
http://blog.bf-itservice.de/471/evoluted-net-php-directory-listing-xss-vulnerability
Thank you,
Benjamin
Stewart Doxey
August 26, 2011 at 5:17 pmHi Benjamin.
Thanks for the information, this issue has been resolved.
Stewart
Attila
July 09, 2011 at 5:39 pmThanks, this is what I need!
Chris
July 11, 2011 at 4:43 amWhen showing the sub-directories they have an “/” on the end of them. Is there a way to not show the “/” on the end of each sub-directory?
AWESOME script by the way!
Chris
July 13, 2011 at 11:30 pmHey loving the script. I have played with it some today. I ended up making a mobile CSS for it. So now when I access it on my android it is a bare display. I am working on the pagination part of it now. Will share with you guys when I get it done. Thanks again for this!
Charliefez
July 18, 2011 at 4:28 pmFantastic,
This was obviously a lot of work and youve made my life so much easier….
one question tho
when i set $forcedownload = true, it allows me to download smaller files, but larger files download only as 1kb files and wont play. Im not sure if this is a problem with the php or if there is a variable im completely missing to limit the downloaded file size??
any help would be awesome, thank you for the code!
Gerard
October 06, 2012 at 6:33 pmCharlie, I read your post about the forcedownload in the directory listing.
I want paople to download rather than view the file.
Where in the script would I place the line?
Can you help me with that?
Charliefez
July 19, 2011 at 1:33 pmHi the way i fixed the width issue is purely with the css:
first change #container to the overall desired width
next change #headerfile to the width you want the file column to be
then change [#listing a] to 40ish px less then your #container
[#listing a strong] gets changed to the width of your file column
next change [#listing a span] to the negative value of half of you file column. for example i changed [#listing a strong] to 490px, so [#listing a span] is -245px
[#listing a em] will be tricky, you have to play around with it depending on how wide everything else is, but change it by 25px in either direction until you find one that works
I hope i could help someone with this, if anyone could figure out the large file download issue please let me know! or that delete button feature, that would be cool although it would probably require a lot of change…
Don McKenzie
July 25, 2011 at 11:15 pmThanks Charliefez,
took a little while to realize that you needed to change styles.css file.
I gave it a try, but found a little of it was ambiguous for me, so I am hoping you can assist further.
I wanted to extend the width by 32 characters.
I worked my way though the listing as per your instructions, and I ended up with a wider display, but two lines for every file name listing.
Is it possible to give actual figures that should work for me?
It would be appreciated very much.
one of the few things that restricts this nice little program.
SEO friendly would be great, and Pagination.
My page is at:
http://www.themaximitecomputer.com/max/Programs/
Cheers Don…
Don McKenzie
July 26, 2011 at 7:07 amI finally sifted through it, and it appears to work:
changes to file styles.css
first change #container to the overall desired width
changed from 600 to 800
next change #headerfile to the width you want the file column to be
changed from 320 to 520
then change [#listing a] to 40ish px less then your #container
changed from 568 to 760
[#listing a strong] gets changed to the width of your file column
changed from 300 to 520
next change [#listing a span] to the negative value of half of you file column.
for example i changed [#listing a strong] to 490px, so [#listing a span] is
-245px
changed from -151 to -260
[#listing a em] will be tricky, you have to play around with it depending on how
wide everything else is, but change it by 25px in either direction until you
find one that works
have no idea what this does.
==============================
changes to index.php
if(strlen($filename)>78) {
changed the file name length test from 43 to 78,
and the next line from 40 to 75.
Cheers Don…
Charliefez
July 26, 2011 at 2:15 pmOk perfect im glad you got it. My setting are all here in case you still have something you want to fix
#container {
width: 750px;
height:450px;
margin-left:auto;
margin-right:auto;
border: 1px solid #CCCCCC;
padding: 9px;
background-color:#FFFFFF;
}
#listingcontainer {
height:450px;
overflow:scroll;
background-image:url(bg.gif);
padding: 10px;
background-color:#E0DEDE;
}
#headerfile {
text-align:left;
float: left;
width: 380px;
}
#headersize {
text-align:right;
width: 150px;
float: left;
}
#listing a {
display:block;
padding: 2px 5px 2px 5px;
font-size:small;
color: #6285CA;
font-family:Arial, Helvetica, sans-serif;
text-decoration:none;
width:710px;
text-align:right;
}
#listing a strong {
width: 390px;
float:left;
cursor:hand;
cursor:pointer;
text-align:left;
}
#listing a em {
float: left;
width: 100px;
text-align:right;
cursor:hand;
cursor:pointer;
}
#listing a span {
width:720px;
position: absolute;
margin-left: -341px;
margin-top: -2px;
}
#listing a span img {
width: 150px;
background-color:#CCCCCC;
visibility: hidden;
}
Alice Leuchte
July 20, 2011 at 12:40 amBrilliant, gorgeous and simple! Thank you!!
Ayanami
July 21, 2011 at 9:30 amThis php code is AWESOME !
Julian
July 27, 2011 at 11:29 pmFabulous – exactly what I wanted. GREAT bit of programming !!!
Don McKenzie
August 04, 2011 at 12:53 amI found when the date stamp went from Jul to Aug, the alignment of the whole thing went out of whack.
So for a 75 character file name, my full settings are given below:
My page is at:
http://www.themaximitecomputer.com/max/Programs/
Cheers Don…
=======================
body {
background-color: #E6E6E6;
}
h1 {
color: #6699FF;
font-family: Arial, Helvetica, sans-serif;
font-weight:bold;
font-size: medium;
margin: 0 0 10px 8px;
padding:0;
}
img {
border: 0;
}
form {
margin: 0;
padding: 0;
}
#container {
width: 807px;
margin-left:auto;
margin-right:auto;
border: 1px solid #CCCCCC;
padding: 9px;
background-color:#FFFFFF;
}
#breadcrumbs {
color: #6699FF;
font-family: Arial, Helvetica, sans-serif;
font-size:small;
margin: 0 0 8px 8px;
}
#breadcrumbs a, #breadcrumbs a:visited, #breadcrumbs a:link, #breadcrumbs a:active {
color: #6699FF;
text-decoration:none;
}
#breadcrumbs a:hover {
text-decoration:underline;
}
#listingcontainer {
background-image:url(bg.gif);
padding: 10px;
background-color:#E0DEDE;
}
#listingheader {
color: #476BB3;
font-weight:bold;
font-family:Arial, Helvetica, sans-serif;
font-size:small;
text-align:right;
}
#listingheader a, #listingheader a:active, #listingheader a:visited, #listingheader a:link {
text-decoration: none;
color: #476BB3;
}
#listingheader a:hover {
text-decoration: underline;
color: #476BB3;
}
#headerfile {
text-align:left;
float: left;
width: 520px;
}
#headersize {
text-align:right;
width: 75px;
float: left;
}
#listing {
border: 1px solid #A7C5FF;
}
#listing a {
display:block;
padding: 2px 5px 2px 5px;
font-size:small;
color: #6285CA;
font-family:Arial, Helvetica, sans-serif;
text-decoration:none;
width:775px;
text-align:right;
}
#listing a:hover {
background-color:#DBE6FE;
}
#listing a img {
float:left;
margin-right: 4px;
}
#listing a strong {
width: 520px;
float:left;
cursor:hand;
cursor:pointer;
text-align:left;
}
#listing a em {
float: left;
width: 75px;
text-align:right;
cursor:hand;
cursor:pointer;
}
#listing a span {
position: absolute;
margin-left: -260px;
margin-top: -2px;
}
#listing a span img {
width: 150px;
background-color:#CCCCCC;
visibility: hidden;
}
#listing a:hover span img {
border: 1px solid #666666;
visibility: visible;
}
#upload {
border: 1px solid #A7C5FF;
display:block;
margin-top: 10px;
font-size:small;
color: #6285CA;
font-family:Arial, Helvetica, sans-serif;
text-decoration:none;
width:568px;
background-color: #E9F0FF;
}
#uploadtitle {
background-color: #DBE6FE;
padding: 2px 5px 2px 5px;
border-bottom: 1px solid #A7C5FF;
}
#uploadcontent {
padding: 2px 5px 2px 5px;
}
#copy {
width: 600px;
margin-left:auto;
margin-right:auto;
text-align:center;
font-size:x-small;
color: #666666;
font-family:Arial, Helvetica, sans-serif;
}
#copy a {
text-decoration: underline;
color: #666666;
}
.b {
background-color: #E9F0FF;
}
.w {
background-color:#FFFFFF;
}
.mod {
float:right;
}
.size {
float:right;
}
.upload-error{
padding:2px 0;
}
.upload-error strong{
color:#993333;
}
Scooby-2
February 10, 2013 at 6:53 pmThanks for sharing this, Don. A good and working mod to a good script.
Dungeon
August 27, 2011 at 2:01 pmLove the script – been using it for some years until I did a search to find that there’s an updated version!
Coupla tips I’d like to see:
1. Separate out the script into a config.php and index.php so that changing config settings “overrides” any index settings. Also, use constants (define) where possible, parametrising things like date display format, allowing uploads, optional H1 site title header.
2. Split the CSS file into a positional (widths, font sizes) and a theme (colours, typeface, background, etc). That way people can tinker with one to change widths without breaking colour stuff – and also makes it easier for people to provide some different colour stylesheets whilst allowing sites to retain their custom widths.
3. Last bit, but a minor one – include some changelog as an audit trail in the file. The last package I downloaded contained two index.php files with differences between them and it’s not obvious which one is the later file (both have “V3″) – consider some minor version control, v3.12 or so, or a changelog to show what differences are.
4. Can the “$hide” array take pattern-matching at all? (eg: *.php, \.php$).
Minor gripes to a major piece of work, guys. Looking forward to the next incarnation!
Kieran
September 01, 2011 at 2:55 pmsorted Ta.
still a bloody marvellous script.
cheers
Simon Bird
September 05, 2011 at 4:36 pmExcellent script – thanks for this. And thanks to Charliefez and Don McKenzie for the CSS stuff with the width adjustment – all very helpful!
warren
October 09, 2011 at 12:15 pmThis is an excellent piece of work, Ash. Really excellent.
It’s just what I’ve been looking for.
Would be even better if it could also display file metadata (title, subject, author, categories, etc).
Philippe
October 12, 2011 at 11:00 amThanks for this super little script, I ran into a problem with special characters in files, like ô en é, I changed the script and put utf8_decode around every mention of $files[i$] which is the filename if I am not mistaken. It would be nice to have this in one single variable like $filename, that way you only need to add the decode ones.
Don McKenzie
October 17, 2011 at 9:08 pmAs there have been no comments for 2 months, I assume the code I posted for 75 characters is working OK.
SEO URLs would be nice.
Cheers Don…
JASPRIT SINGH
October 21, 2011 at 9:04 amFirstly i Want To Thanks the Maker.
hello, friends i have make it some custom, hope u would like it.
it’s simple. goto dlf folder just change the CSS file and watch it.
********************************
Red Theme – Php Directory Script
********************************
/* Start From Here. */
body {
margin-top: 1cm;
background-color: #E6E6E6;
}
h1 {
color: #ff6666;
font-family: Arial, Helvetica, sans-serif;
font-weight:bold;
font-size: medium;
margin: 0 0 10px 8px;
padding:0;
}
img {
border: 0;
}
form {
margin: 0;
padding: 0;
}
/* frame */
#container {
width: 800px;
margin-left:auto;
margin-right:auto;
border: 1px solid #CCCCCC;
padding: 9px;
background-color:#FFFFFF;
}
#breadcrumbs {
color: #ff6666;
font-family: Arial, Helvetica, sans-serif;
font-size:small;
margin: 0 0 8px 8px;
}
#breadcrumbs a, #breadcrumbs a:visited, #breadcrumbs a:link, #breadcrumbs a:active {
color: #ff6666;
text-decoration:none;
}
#breadcrumbs a:hover {
text-decoration:underline;
}
#listingcontainer {
background-image:url(bg.gif);
padding: 10px;
background-color:#E0DEDE;
}
#listingheader {
color: #cc3366;
font-weight:bold;
font-family:Arial, Helvetica, sans-serif;
font-size:small;
text-align:right;
}
#listingheader a, #listingheader a:active, #listingheader a:visited, #listingheader a:link {
text-decoration: none;
color: #cc3366;
}
#listingheader a:hover {
text-decoration: underline;
color: #cc3366;
}
#headerfile {
text-align:left;
float: left;
width: 320px;
}
#headersize {
text-align:right;
width: 275px;
float: left;
}
#listing {
border: 1px solid #ff9999;
}
#listing a {
display:block;
padding: 2px 5px 2px 5px;
font-size:small;
color: #cc6666;
font-family:Arial, Helvetica, sans-serif;
text-decoration:none;
width:768px;
text-align:right;
}
#listing a:hover {
background-color:#ffcccc;
}
#listing a img {
float:left;
margin-right: 4px;
}
#listing a strong {
width: 300px;
float:left;
cursor:hand;
cursor:pointer;
text-align:left;
}
#listing a em {
float: left;
width: 275px;
text-align:right;
cursor:hand;
cursor:pointer;
}
#listing a span {
position: absolute;
margin-left: -151px;
margin-top: -2px;
}
#listing a span img {
width: 150px;
background-color:#CCCCCC;
visibility: hidden;
}
#listing a:hover span img {
border: 1px solid #666666;
visibility: visible;
}
#upload {
border: 1px solid #ff9999;
display:block;
margin-top: 10px;
text-align:center;
font-size:small;
color: #cc6666;
font-family:Arial, Helvetica, sans-serif;
text-decoration:none;
width:777px;
background-color: #fff;
}
#uploadtitle {
background-color: #ffe9ef;
padding: 2px 5px 2px 5px;
border-bottom: 1px solid #ff9999;
}
#uploadcontent {
padding: 2px 5px 2px 5px;
}
#copy {
width: 600px;
margin-left:auto;
margin-right:auto;
text-align:center;
font-size:14px;
font-weight:bold;
color: #666666;
font-family:Arial, Helvetica, sans-serif;
}
#copy a {
text-decoration: underline;
color: #666666;
}
.b {
background-color: #ffe9ef;
}
.w {
background-color:#FFFFFF;
}
.mod {
float:right;
}
.size {
float:right;
}
.upload-error{
padding:2px 0;
}
.upload-error strong{
color:#993333;
}
/* Css File End */
Brian Turner
October 21, 2011 at 4:57 pmI added
ob_end_flush();
just before this line
readfile($includeurl . $leadon . $file);
and fixed the problem.
I don’t know if that hoses something else.
According to the php.net discussion on readfile that turns off output buffering and makes file transfers not dependent on PHP memory.
Werner Coetzee
October 26, 2011 at 2:33 pmThought I should mention this:
To make the script read KB, MB, GB and TB automatically instead of only KB put this function somewhere in the script
$path = “.”; // = 1099511627776) {
$value = round($size_in_bytes/1099511627776*10)/10;
return ($round) ? round($value) . ‘Tb’ : “{$value} TB”;
} else if ($size_in_bytes >= 1073741824) {
$value = round($size_in_bytes/1073741824*10)/10;
return ($round) ? round($value) . ‘Gb’ : “{$value} GB”;
} else if ($size_in_bytes >= 1048576) {
$value = round($size_in_bytes/1048576*10)/10;
return ($round) ? round($value) . ‘Mb’ : “{$value} MB”;
} else if ($size_in_bytes >= 1024) {
$value = round($size_in_bytes/1024*10)/10;
return ($round) ? round($value) . ‘Kb’ : “{$value} KB”;
} else {
return “{$size_in_bytes} B”;
}
}
and then to change the displaying of file sizes change KB to
And to display dir sizes the same way replace - with
Sample can be viewed at http://www.imtechnology.co.za/data/index.php, allthough I cannot gaurentee how long the sample will be kept there, as I am only borrowing the webspace from a friend for the time being.
cheers. W
FreaqyGeeq
May 31, 2012 at 5:48 amHi Werner.
I’m really interested in your filesize solution here, but your instructions seem a bit incomplete. Can you please explain what needs to be changed in the existing code to enable your filesizes? Thank you very much in advance!
FG.
Modustollens
October 26, 2011 at 5:54 pmGreat script!
I made a few modifications for file name size. But I don’t really need to have either the file size or date showing in the table and I could not figure out how to edit the script to not include these; perhaps you could make that into a configurable option?
Either way – great script – far superior to one I was using for this sort of task for the last couple of years.
partime
November 03, 2011 at 4:10 pmHey
Great script, easy to configure and very clear instruction for editing.
Thanks for the script!
Mike
November 12, 2011 at 12:09 amThis is really awesome, thanks for putting this up
Osowo
November 16, 2011 at 8:46 amThanks Bro! finally figured everything out.
advice to those that want to use this script, just copy the “/dif folder and index.php file” into the directory you want to make listing directory display.
Ben
November 17, 2011 at 9:42 pmMany thanks for making it for everyone. It is such a great app and you put it for free!
One question: I am going to use for listing files in different Linux boxes. Is it possible to have it to access cross other machine?
Thanks again
- Ben
Tom
November 21, 2011 at 5:29 pmGreat script! Thanks!
Mario
November 23, 2011 at 10:05 amGreat script, worked with no problems.
Aden
November 24, 2011 at 3:14 amOmg been looking for something like this for ages! D: thank you very much!
Dave
December 04, 2011 at 7:19 pmMy thoughts exactly!
str9led
November 24, 2011 at 12:55 pmVery nice script.
Lucas
November 25, 2011 at 1:34 pmHello, great script
Can i use it on commercial site?
Ps. Thanks again.
Ash Young
November 26, 2011 at 1:14 pmYes Lucas, you are free to use this on a commercial site.
Lucas
November 28, 2011 at 12:45 pmThanks
bastetx
November 26, 2011 at 1:01 pmGreat script, have used since v1, on v3 could not get it to include in another web page no matter what .. never mind was only playing anyway, thanks for the hard work
SkyLines
November 28, 2011 at 9:51 amThis is best script I ever used for directory listing.
But this would be World’s Best if Pagination and Adsense ad placement below or above the list is added in future releases.
Thanks!
stan
December 02, 2011 at 8:11 pmfantastic script! With only slight customizations I use the script for a private CD/DVD database. Much appreciated; all the work that has gone into this script…
Dave
December 04, 2011 at 7:18 pmWow – what an absolutely fantastic script – THANKS!!!!!
This has just become one of my favorite sites – wish I would have stumbled upon you guys sooner.
Werner Coetzee
December 14, 2011 at 8:36 amHi!
I have copied the script partially into my website. And I think I noticed something went wrong. If I have images, and anything listed beneath the images. And you move with your mouse on the file below the image, from the file name to the size, just before you reach the size, the mouse jumps up to the image’s line, and shows the image as thumbnail. I suspect its some CSS setting about width that needs to be modified, but I cannot find the correct one. Could you perhaps point it out to me?
Werner Coetzee
December 14, 2011 at 1:07 pmI noticed the same thing with the demo. If you move your mouse to just below the last modified column, at the bottom of the listing, it jumps to the lowers image file (jpg, png etc) in the list and displays its thumbnail.
I managed to find out which css style setting is used to move that image to the right or left, its the #listing a span, as I thought it was a spacing issue
Any ideas on how to prevent this from happening when thumbs is enabled?
VAHID
December 22, 2011 at 10:51 amReally Thanks for this script.
its really useful !!!
TARIK TURAN
January 06, 2012 at 12:30 amVery nice script and great job !
Roman
January 06, 2012 at 10:09 amHey, thanks very much for that script!
I use it for my intranet on a Synology DSM and helps a lot!
Carry on like this
Anuj
January 08, 2012 at 5:49 pmThanks to Ash Young (for Making Script) and Don McKenzie( for fixing issue for which he suggested solution).
Norm Jurgen
January 10, 2012 at 2:52 amI am curious if you can assist me in implementing your script to display folders and subfolders?
Link to a development site is below:
http://www.jjmcguire-dev.com/current-projects.php
Requires a login & password:
login: *****
password: *****
I’ve included your script in existing PHP code and set it up to scan a folder,
$startdir =
projects/government-municipalities/000001susanban/images/
However, the script cannot scan sub folders.
Any help would be appreciated.
Norm Jurgen
January 10, 2012 at 4:56 pmI placed a draft for you to review on,
http://www.jjmcguire-dev.com/project-view-draft.php?project_id=1
I am curious if I can use this product and if there is a cost associated with using it?
Also, can you assist me in displaying subfolders?
Norm Jurgen
January 11, 2012 at 2:41 pmI ended up getting your script to work however it conflicted with existing PHP code (which I had to strip out). Not sure where the issues were. Never heard back from you about using your product. I kept your credits on the page. Here is a link for your review,
http://www.jjmcguire-dev.com/bid-view-documents.php
It is an excellent script. Thank you.
Ash Young
January 18, 2012 at 8:40 amSorry I was a little slow with a response Norm, your page looks great.
Just to confirm you are free to use the script as you see fit.
Dave
May 14, 2012 at 12:48 pmHi Norm. Your listing looks great. Can I ask how you set the width of the control? I would like the overall width of the control no more than say 5cm, currently I can’t find a width property.
Kind Regards
Dave
MCBUrner
March 21, 2012 at 11:37 amHi. Fantastic and very helpful script. Thanks for your great work! There is just one “problem” I found – and I couldn’t fix it as yet. If there are files in a directory with more than one dot in the full file name like “whatever.date.pdf” – these files are not shown. As – in my case – there are many of those files – I would like to fix it in the script. And not by renaming all the files
Any ideas?
MCBurner
March 21, 2012 at 5:57 pmHi. It looks like I solved it and I would like to share my changes with you guys as it might help you. Please don’t wonder – I’m not a programmer so it’s maybe “quick n dirty”.
I changed line 319 from
“if($showtypes && !in_array(substr($file, strpos($file, ‘.’)+1, strlen($file)), $showtypes)) unset($file);”
to the following
“#check the string length for full file name + type
$get_stringlength = strlen($file);
#get the last string right after the last dot
$get_typestring = substr(strrchr($file, ‘.’),$get_stringlength*(-1));
#assume that everything before it belongs to the filename and calculate the string length
$get_typelength = $get_stringlength – strlen($get_typestring);
#now use the knowledge about the typelength as the position for strpos
if($showtypes && !in_array(substr($file, strpos($file, ‘.’, $get_typelength)+1, strlen($file)), $showtypes)) unset($file);”
gallar
March 26, 2012 at 12:35 pmBig thanks, GREAT and FANTASTIC job!
Tessa Mero
March 27, 2012 at 7:15 pmVery nice script. Way better than the one I found for ASP. The only thing this code is missing is a search bar. But I’m sure anyone knows how to include that.
72
April 15, 2012 at 1:35 pmThanks! Works excellent!
xfr
April 18, 2012 at 4:42 pmFYI this script does not play nice with a symlink to a directory. It is not displayed as a directory and is offered as a 0 byte download instead.
Roland
June 13, 2012 at 8:32 pmYes, same problem.
The script is great, but if I can’t use symlinks, I can’t use the script.
@Ash: are you going to support symlinks in further versions?
Roland
June 13, 2012 at 8:48 pmOk, solved the problem:
in line 303 (or so – search for “dir” with the quotation marks) you will find
if (@filetype($includeurl.$leadon.$file) == “dir”) {
extend this to
if ((@filetype($includeurl.$leadon.$file) == “dir”) OR (@filetype($includeurl.$leadon.$file) == “link”)) {
This will handle symlinks just like dirs
Callum
May 04, 2012 at 10:35 amJust stumbled across this script, its great. Thank you very much!
Martin
May 09, 2012 at 9:15 pmThanks very much
cahboy
May 18, 2012 at 8:57 amVery nice script and so useful thanks for sharing.
Mohammad Mirzaei
June 24, 2012 at 10:20 amThanks much! Very usefull script!
McFire
June 24, 2012 at 2:10 pmYeah – thats it!!!
Uploaded |dlf| and the index.php and – it works! Also in the last corner of my site!
The only thing I miss : I’d like to store the content of the actual shown dir/subdir into a simple text file. So I could write me a little “app” to sum the bytes of the subdir.
Or is there even planned such a count/sum function? And having it in a text it also could be helpful at work with my ftp.
Greetings and thanx for this script.
Henrik Bechmann
June 24, 2012 at 6:04 pmNice script Ash, but apparently the styles.css “#listing a strong” at line 113 needs a “white-space:nowrap” rule added to avoid a word wrap on a hyphen for a long file name. Such a wrap/break causes following formatting to get mangled.
Hope this helps.
- Henrik
Henrik Bechmann
June 24, 2012 at 6:18 pmAlso it appears that
overflow:hidden;
text-overflow:ellipsis;
works for listing a strong instead of truncating the filename.
- Henrik
McFire
July 05, 2012 at 11:44 pmI’ve changed some things in styles.css , so it’s extendet now to 900px. With the help of some hints from here it was done successful. Also changed the assiciated pts in index.php to 75 resp. 72 . But despite of having more space now the filenames doesn’t expand. What is to do?
McFire
July 06, 2012 at 1:50 amFixed a selfconstructed bug, now it runs correct. And here I’ve set a picture with all needed stuff for expanding the dir window.
http://www.letterchip.de/kramkiste/dirliststructure.gif
So you have all at one single point.
Thanks again to all helpful hint writers here.
Sandor
October 22, 2012 at 11:01 amIt would be great if the script could show directory headers. Maybe in a new version?
Ash Young
November 06, 2012 at 11:16 pmWhat do you mean by directory headers?
Sandor
November 07, 2012 at 8:31 amAn html file (i.e header.html and footer.html) with text to display in header and footer of the directory listing.
It would also be interesting files.bbs or descript.ion support, for files comments…
Ron
November 28, 2012 at 11:22 amMuch appreciated. The exclude list is maybe its best feature making it easy to limit a user to only the file types we want them to see. I may eventually add code to GET[..] a variable and so modify the exclusion list depending upon login.
Thank you very much for your hard work.
Mark Jones
December 03, 2012 at 6:12 pmExcellent script! Thanks for the time and effort you guys put into it.
I was just wondering if anyone has worked out how to implement a delete button?
Thanks,
Jonesy
Mark Jones
December 04, 2012 at 1:50 amFigured it out!
So, to add a delete option to my file listings output I just added another link right after the file link. The href in the new link contains this php echo statement:
echo strip_tags($_SERVER['PHP_SELF']).’?deletefile=’.$fileurl;
And in the same index.php file I added this php coding:
if(isset($_GET['deletefile'])){
$deletefile = $_GET['deletefile'];
unlink($deletefile);
}
I also added some additional styling to get everything lined up properly. For my specific purposes I already had security protocols in place so the DELETE link is only available to specific logged in users.
Hope this helps!
Jonesy
Martin Clay
January 05, 2013 at 5:03 pmHi guys, this script is great. It’s the best one I’ve found so far. I’m using it to list mp3 file on my DJ site. Just one issue however, if the file name has more than one . in it , then that file is not displayed. I’m going to write a bit of code to take all .’s out of my file names but it would be good if you could consider a possible fix. Thanks again for a great free script !
Steve Rance
January 12, 2013 at 12:06 amThe best solution out there, thanks Ash. Modified it for my requirements however. http://fairlightus.com/Downloads
Scooby-2
February 10, 2013 at 7:02 pmThanks for a great script. Our site is non-profit making so it’s great to see a professionally written program like this made freely available.
Toby
February 23, 2013 at 12:07 amDear Ash
Very usefull! I would like to donate, but you refused 2 years ago – If you change your mind – let me know.
Anyway – thanks a lot for this script and best wishes from Switzerland
Tobias
helikun
March 21, 2013 at 3:09 pmThank you very much.your code great.
^_^
William Becher
April 16, 2013 at 3:40 amHi, great script. I’ve used this for my personal use. Can I modify the code and add some modifications to the script?
Evoluted New Media
April 26, 2013 at 11:01 pmYes, that’s absolutely fine!