PHP Directory Listing Script

10 August, 2016

Back in 2008 we created the original version of our popular directory listing script. Since then we’ve released three new versions, addressing a number of known issues. In 2015 we completely rebuilt the script from scratch, introducing some handy new features and improvements.

The PHP Directory Listing Script is a highly configurable script, allowing you to simply upload one file into a web-accessible directory, and it’ll be turned into a well formatted, mobile friendly directory browser.

With the release of version 4, we’ve got some great new features, including:

  • Full mobile browser support.
  • The ability to upload multiple files and restrict the allowed file-types.
  • Support for restricting access to the script by either password or IP Address whitelisting (ideal if you want only yourself and clients to have access!).
  • Support for creating new directories and sub-directories.
  • Upload zip files and extract them automatically, with the option to delete the zip file after it’s been extracted.
  • Optionally hide certain file types, names or extensions, as well as directories.
  • Sort file listings by name, size or last modified date.

Finally, the last feature is that the Directory Listing Script now runs as a single file, weighing in at less than 400kb. This means the script runs faster, and is extremely easy to use!

All of the new features can be enabled and disabled individually, so whether you’re looking for a full file manager, or a simple list of downloads, the PHP Directory Listing script has you covered.

System Requirements

To run the PHP Directory Listing Script on your website, you’ll need to be running PHP 5.3 or above and have the GD2 library installed. If you wish to enable the unzip support, you’ll also need the ZipArchive php extension installed.

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.

Installation

To install the PHP Directory Listing Script, simply extract the zip file and open up the index.php file. Inside you’ll see a number of options that you can alter. Once you’ve set your options, simply upload the file into your directory and then browse to it from the web. You should now be up and running!

Future

We’re always open to feedback for improvements and suggestions so please leave any ideas in the comments section below and we’ll do our best to incorporate them into a future update.

Written by Ash

Having co-founded Evoluted in 2006, Ash’s passion for the digital world and obsession with client satisfaction has since helped the company grow into one of Yorkshire’s leading digital agencies. An advocate of ROI-focused delivery and a firm believer in the use of bespoke technology, he was nominated for ‘Business Person of the Year’ at the 2017 Sheffield Business Awards.

Up next…
Drumroll, Please
10 August, 2016

191 Comments

Patrick
16th October 2017 at 9:16am

First: 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.

Post reply
Aldo
16th October 2017 at 9:16am

Love 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?

Post reply
Ash
16th October 2017 at 9:16am

Thanks for the comment Patrick, we'll take a look at the bugs and get a new version posted ASAP.

Post reply
ali
16th October 2017 at 9:16am

Hello sir i want to make a trigger for PDF or other files in my directory. this trigger will redirect the page to showFile page to show this clicked file? how ?

Post reply
lolo
16th October 2017 at 9:16am

Thanks much! Very usefull script!
I'll be happy to get that correction concerning the subdirectories problem

Post reply
Matt
16th October 2017 at 9:16am

Hey, thanks for the nice script. I could definitely use the solution to the sub directories problem as well. Cheers...

Post reply
Patrick
16th October 2017 at 9:16am

Okay, thanks. Maybe the include solution is the reason why i cant set the standard subdirectory...i dont know. The demo works fine. :(

Post reply
Dmitry Garanin
16th October 2017 at 9:16am

I 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.

Post reply
James Thomas
16th October 2017 at 9:16am

Hi 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.

Post reply
Matt Cram
16th October 2017 at 9:16am

Thanks to Ash, James, and team for the V3 update...

Post reply
Tomas
16th October 2017 at 9:16am

This is really a GREAT WORK!!! You saved my *ss! Thanks a lot! Everything works fine, even that "subdir browsing" Patrick talked about. Thanks again!

Post reply
CaliVW78
16th October 2017 at 9:16am

First 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!

Post reply
Ash
16th October 2017 at 9:16am

Thanks for the comment, no donation is required!

We're looking at pagination for a future release.

Post reply
Mister Smith
16th October 2017 at 9:16am

Looks 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

Post reply
Ash Young
16th October 2017 at 9:16am

Do you have an example of where you've tried to use the script with longer filenames?

Post reply
peter
16th October 2017 at 9:16am

When 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.

Post reply
Don McKenzie
16th October 2017 at 9:16am

Does 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...

Post reply
Edgar
16th October 2017 at 9:16am

SEO friendly urls would be very nice. Right now the output looks very scary.

Post reply
tygrysalex
16th October 2017 at 9:16am

SEO friendly urls + pagination = THE BEST Directory Listing Script

Please, do it for humanity ;)

Post reply
yinka
16th October 2017 at 9:16am

This is the best free PHP directory script so far.

Post reply
akhtar
16th October 2017 at 9:16am

Hi,
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

Post reply
satwik
16th October 2017 at 9:16am

Hi

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.

Post reply
Artax
16th October 2017 at 9:16am

Simply hit Ctrl+F and you'll get a nifty search box. ;-)

Post reply
Eric
16th October 2017 at 9:16am

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?

Post reply
Eric
16th October 2017 at 9:16am

No ideas?

Post reply
Ukyo
16th October 2017 at 9:16am

Nice script!

I second the "pagination" motion, it'd be nice for directories with a big number of files.

Post reply
Adam
16th October 2017 at 9:16am

This works just great!
Thanks for sharing :-)

Post reply
JT
16th October 2017 at 9:16am

Would 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!

Post reply
Scott
16th October 2017 at 9:16am

Hello, 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!

Post reply
armin
16th October 2017 at 9:16am

Woow, Very Nice script. That was very useful. Thanks

Post reply
php4pro
16th October 2017 at 9:16am

there is a problem if i put folder path instead of '.' it's working but the sub folder contents not appear?

Thank you

Post reply
James Thomas
16th October 2017 at 9:16am

Hi there,
This issue has been addressed; setting a path in $startdir should no longer prevent files from displaying.

Post reply
Dinaker
16th October 2017 at 9:16am

Hello,

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.

Post reply
Dan T
16th October 2017 at 9:16am

To enable uploads, just activate the one variable:
$allowuploads = true;

(file size is up to 8 megs)

Post reply
Linda
16th October 2017 at 9:16am

I 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?

Post reply
Dan Eliot
16th October 2017 at 9:16am

LOVE 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?

Post reply
Dan Eliot
16th October 2017 at 9:16am

Also... is this V2 or V3? The ZIP says V3, but the comments in the script say V2??

Post reply
James Thomas
16th October 2017 at 9:16am

Hello Dan,
The comments in the code have been updated accordingly.

Post reply
Ratio
16th October 2017 at 9:16am

Hey,

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

Post reply
Mads
16th October 2017 at 9:16am

Hey 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/

Post reply
James Thomas
16th October 2017 at 9:16am

Hi 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!

Post reply
schiho
16th October 2017 at 9:16am

Hi, i would like to know if you can run this script locally when setting the www path under php.ini to C:\outputs\

thanks!

Post reply
Cris
16th October 2017 at 9:16am

Sorry for my English. I'm using Google translator.
Excellent script!!!
Ash, It can be used for ftp?
What should change?

Thanks

Post reply
Italic Remover
16th October 2017 at 9:16am

Can the italic be removed from file sizes? I can't seem to find the code for it in the files.

Post reply
Cizzz
16th October 2017 at 9:16am

Add font-style:normal in CSS #listing a em

Post reply
sacha
16th October 2017 at 9:16am

This 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 !

Post reply
arifwicaksono
16th October 2017 at 9:16am

very 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 ?

Post reply
James Thomas
16th October 2017 at 9:16am

Hi 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.

Post reply
Rob
16th October 2017 at 9:16am

Hi. 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

Post reply
James Thomas
16th October 2017 at 9:16am

Hi 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.

Post reply
Christian
16th October 2017 at 9:16am

HI,

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

Post reply
Jai Gopal Kumar
16th October 2017 at 9:16am

I 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.

Post reply
Pierre
16th October 2017 at 9:16am

Hi. 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.

Post reply
Cbr
16th October 2017 at 9:16am

Works like a charm ! Thank you :)
Have also tried to work it out. Anyone solved this or has any idea ?

Post reply
Pierre
16th October 2017 at 9:16am

Ooh 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?

Post reply
Mike
16th October 2017 at 9:16am

This is a great script! It saved me hours of doing this directory listing by hand!

Post reply
Eric
16th October 2017 at 9:16am

I 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?

Post reply
Ratio
16th October 2017 at 9:16am

I only wnat to Display .rar or .zip files.

A way through this???

Post reply
James Thomas
16th October 2017 at 9:16am

Hello Ratio,
We've added a new array called "$showtypes" which will only allow speficied file types to be displayed.

Post reply
Dedeniz
16th October 2017 at 9:16am

Great work, thanks so much ;)

Post reply
b0y
16th October 2017 at 9:16am

hi bro... thanks for your'e script....
it's realy great code... :D
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. :D
thanks brother

Post reply
James Thomas
16th October 2017 at 9:16am

Hi 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.

Post reply
b0y
16th October 2017 at 9:16am

hi bro thanks for your attention :D
where i can place new array “$uploadtypes” cos in dirlistingv3 i can't see this array function and command to call :D
thanks for your'e attention my bro :D

Post reply
James Thomas
16th October 2017 at 9:16am

Hi 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!

Ash Young
16th October 2017 at 9:16am

The link above has been updated with a new ZIP file containing the updated PHP.

b0y
16th October 2017 at 9:16am

hi bro... :D 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
https://www.evoluted.net/assets/thinktank/wp-content/uploads/2011/02/dirlistingv3.zip

thanks my bro :D

b0y
16th October 2017 at 9:16am

hello again my bro :D
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
https://www.evoluted.net/assets/thinktank/wp-content/uploads/2011/02/dirlistingv3.zip

so where i can get new version for this script :D
thanks my bro :D

b0y
16th October 2017 at 9:16am

hi bro :D thanks bro...it's now really new version for listing script. :D
thanks bro :DD

James Thomas
16th October 2017 at 9:16am

Hello 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
16th October 2017 at 9:16am

hi 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

Post reply
Eric
16th October 2017 at 9:16am

Still 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.

Post reply
Dungeon
16th October 2017 at 9:16am

What 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.

Post reply
James Thomas
16th October 2017 at 9:16am

Hi Eric,
Unfortunately this is not a feature we're planning to add at this time.

Post reply
b0y
16th October 2017 at 9:16am

hello 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
https://www.evoluted.net/assets/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

Post reply
Thankful!
16th October 2017 at 9:16am

This 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?

Post reply
Dmitry Garanin
16th October 2017 at 9:16am

The listing is broken on my site http://www.lokshin.org/Scores/

Post reply
Daedalus
16th October 2017 at 9:16am

The 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!

Post reply
Daniel
16th October 2017 at 9:16am

I think exactly the same!

Post reply
ridhoyp
16th October 2017 at 9:16am

Awesome! thank you so much...

Post reply
Mario Fetka
16th October 2017 at 9:16am

thx for the update to your great script.
one thing that always frustrated me a little is the missing support for symlinks.

thx Mario

Post reply
User
16th October 2017 at 9:16am

Thank you. This has been very helpful to me

Post reply
tismon
16th October 2017 at 9:16am

thanks a lot dude..

Post reply
tanveer
16th October 2017 at 9:16am

nice web site
i really like it

Post reply
hikarin
16th October 2017 at 9:16am

Thanks, nice script

Post reply
blepblaad
16th October 2017 at 9:16am

Nice script. Thanks.
The script misplaces the folder icon when a foldername is long.

Post reply
Matt
16th October 2017 at 9:16am

Absolutely 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.

Post reply
Cagsun
16th October 2017 at 9:16am

Great script thank you so much. Saved me a lot of time ;)

Post reply
Mike
16th October 2017 at 9:16am

very nice...... thanks

Post reply
Darren
16th October 2017 at 9:16am

Hi,

How would I go about putting a working delete button next to each file listed?

Post reply
Benjamin Flesch
16th October 2017 at 9:16am

Hello 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

Post reply
Stewart Doxey
16th October 2017 at 9:16am

Hi Benjamin.

Thanks for the information, this issue has been resolved.

Stewart

Post reply
Attila
16th October 2017 at 9:16am

Thanks, this is what I need!

Post reply
Chris
16th October 2017 at 9:16am

When 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!

Post reply
Chris
16th October 2017 at 9:16am

Hey 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!

Post reply
Charliefez
16th October 2017 at 9:16am

Fantastic,
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!

Post reply
Gerard
16th October 2017 at 9:16am

Charlie, 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?

Post reply
Charliefez
16th October 2017 at 9:16am

Hi 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...

Post reply
Don McKenzie
16th October 2017 at 9:16am

Thanks 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...

Post reply
Don McKenzie
16th October 2017 at 9:16am

I 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...

Post reply
Charliefez
16th October 2017 at 9:16am

Ok 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
16th October 2017 at 9:16am

Brilliant, gorgeous and simple! Thank you!!

Post reply
Ayanami
16th October 2017 at 9:16am

This php code is AWESOME !

Post reply
Julian
16th October 2017 at 9:16am

Fabulous - exactly what I wanted. GREAT bit of programming !!!

Post reply
Don McKenzie
16th October 2017 at 9:16am

I 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;
}

Post reply
Scooby-2
16th October 2017 at 9:16am

Thanks for sharing this, Don. A good and working mod to a good script.

Post reply
Dungeon
16th October 2017 at 9:16am

Love 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!

Post reply
Kieran
16th October 2017 at 9:16am

sorted Ta.
still a bloody marvellous script.
cheers

Post reply
Simon Bird
16th October 2017 at 9:16am

Excellent script - thanks for this. And thanks to Charliefez and Don McKenzie for the CSS stuff with the width adjustment - all very helpful!

Post reply
warren
16th October 2017 at 9:16am

This 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).

Post reply
Philippe
16th October 2017 at 9:16am

Thanks 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.

Post reply
Don McKenzie
16th October 2017 at 9:16am

As 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...

Post reply
JASPRIT SINGH
16th October 2017 at 9:16am

Firstly 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 */

Post reply
Brian Turner
16th October 2017 at 9:16am

I 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.

Post reply
Werner Coetzee
16th October 2017 at 9:16am

Thought 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

Post reply
FreaqyGeeq
16th October 2017 at 9:16am

Hi 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.

Post reply
Modustollens
16th October 2017 at 9:16am

Great 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.

Post reply
partime
16th October 2017 at 9:16am

Hey

Great script, easy to configure and very clear instruction for editing.

Thanks for the script!

Post reply
Mike
16th October 2017 at 9:16am

This is really awesome, thanks for putting this up :)

Post reply
Osowo
16th October 2017 at 9:16am

Thanks 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.

Post reply
Ben
16th October 2017 at 9:16am

Many 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

Post reply
Tom
16th October 2017 at 9:16am

Great script! Thanks!

Post reply
Mario
16th October 2017 at 9:16am

Great script, worked with no problems.

Post reply
Aden
16th October 2017 at 9:16am

Omg been looking for something like this for ages! D: thank you very much!

Post reply
Dave
16th October 2017 at 9:16am

My thoughts exactly!

Post reply
str9led
16th October 2017 at 9:16am

Very nice script.

Post reply
Lucas
16th October 2017 at 9:16am

Hello, great script :)
Can i use it on commercial site?
Ps. Thanks again.

Post reply
Ash Young
16th October 2017 at 9:16am

Yes Lucas, you are free to use this on a commercial site.

Post reply
Lucas
16th October 2017 at 9:16am

Thanks :)

Post reply
bastetx
16th October 2017 at 9:16am

Great 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

Post reply
SkyLines
16th October 2017 at 9:16am

This 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!

Post reply
stan
16th October 2017 at 9:16am

fantastic 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...

Post reply
Dave
16th October 2017 at 9:16am

Wow - what an absolutely fantastic script - THANKS!!!!!

This has just become one of my favorite sites - wish I would have stumbled upon you guys sooner.

Post reply
Werner Coetzee
16th October 2017 at 9:16am

Hi!
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?

Post reply
Werner Coetzee
16th October 2017 at 9:16am

I 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?

Post reply
VAHID
16th October 2017 at 9:16am

Really Thanks for this script.
its really useful !!!

Post reply
TARIK TURAN
16th October 2017 at 9:16am

Very nice script and great job !

Post reply
Roman
16th October 2017 at 9:16am

Hey, thanks very much for that script!
I use it for my intranet on a Synology DSM and helps a lot!

Carry on like this :)

Post reply
Anuj
16th October 2017 at 9:16am

Thanks to Ash Young (for Making Script) and Don McKenzie( for fixing issue for which he suggested solution).

Post reply
Norm Jurgen
16th October 2017 at 9:16am

I 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.

Post reply
Norm Jurgen
16th October 2017 at 9:16am

I 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?

Post reply
Norm Jurgen
16th October 2017 at 9:16am

I 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.

Post reply
Ash Young
16th October 2017 at 9:16am

Sorry 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.

Post reply
Dave
16th October 2017 at 9:16am

Hi 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

Post reply
MCBUrner
16th October 2017 at 9:16am

Hi. 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?

Post reply
MCBurner
16th October 2017 at 9:16am

Hi. 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);"

Post reply
gallar
16th October 2017 at 9:16am

Big thanks, GREAT and FANTASTIC job!

Post reply
Tessa Mero
16th October 2017 at 9:16am

Very 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. ;-)

Post reply
72
16th October 2017 at 9:16am

Thanks! Works excellent!

Post reply
xfr
16th October 2017 at 9:16am

FYI 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.

Post reply
Roland
16th October 2017 at 9:16am

Yes, 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?

Post reply
Roland
16th October 2017 at 9:16am

Ok, 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

Post reply

Leave a comment

Replying to: - Cancel