08.12.08

I’ve been wanting to make a simple script that was entirely self-contained for a while now, but I haven’t been sure on exactly what I wanted to do. Something I’ve done more times than I care to count is write code that reads a directory and displays the files in some form or fashion. It’s something I know inside and out so I figured why not make a directory listing script that uses icons to represent individual file types and embed those images into the script itself. So I started coding.

A few hours later I had an embarrassingly polished script I felt deserved it’s own page. I’ve commented the code as thoroughly as possible, but if you have any questions please ask below.

Project Page: Greg-J.com/phpdl
Demo URL: PHPDL
Download: phpdl.zip

Posted in Uncategorized


Hey, that’s pretty good! Garry Newman has also made a dir listing script some time ago, it automatically displays images as thumbnails as well.

i knew this script, but i dont really know yet -what would you do for this script ? if only for storing your files, you can place just like that on open directory without “index.html” so every body can accessed ?

Hi Floris,

Good ol Garry, you know what they say about great minds…

I got another wild hair and added a few more features last night:

* native support for playing .mov, .wmv and .avi files
* embedded flv player for watching flv videos.
* embedded mp3 player for playing audio files.
* lightbox for viewing images, flash, text and other native files.

I also created a light version for people who don’t want all the fluff and included images. If I have time tonight after work/before bed I’ll finish it up and release it.

Joels,

What you’re referring would require that directory browsing be enabled on apache which most people avoid due to the obvious security issues. This offers a much cleaner solution that is both safer and customizable.

Hi, I’ve uploaded the file ‘as is’ to one of my client’s directories, but the file names aren’t showing, just “.php” or “.pdf”. You can see what I mean at: http://holycrossonline.org/daily_digest/articles/. Have I missed something?

would it be possible for something like this to group things by file type? or produce a number of identifiers (file type, date created, category, etc.) to organize them by?

like viewing in groups in Windows Explorer? example pic

can you think of anything a site host would have turned off that wouldnt allow filenames to show up? example pic

untouched index.php file from v2 that works on another one of my sites with a different, better host.

There is an error on http://greg-j.com/phpdl/ – the “a” tag afer the text “Download PHPDL” is incorrect, so the link to “phpdl.zip” does not work.

Excellent work.
Very easy to use.

My server is on a mac and in some folders, there are hidden files that I don’t want to list (they all begin by .)
So I changed this line (may be this is enough generic to be added in future releases)

// Make sure we don't list this folder, file or their links.
if ($file != "." && $file != ".." && $file != $this_script && !preg_match('/^\./',$file) )

How to add support for pdf preview files in the thickbox ?

hi Jim N.
i have the same problem, the file name is not showing.
and it does not support folder?

I have the same issue as Jim N above. Only the extensions show and that is what it tries to load when you click a link. What do I need to do to get the file name to show too?

Thanks!

Windows XP, Apache 2.2, PHP 5.2.6, and the full version displays its contents. I figured it was the short tags, changed it and now the script does absolutely nothing. The Lite version seems to work well.

Where might I begin looking to see what is going wrong?

Thanks for this file! Great work.

I’m trying to get this to NOT display my .htaccess files, any help would be much appreciated.

I tried Ocococ’s line above but i got an error

Hi
This script will be very useful to me – thanks for making it available.
However I’ve got the same problem as mentioned by Jim N above.

I uploaded the file as is and I only see the extension – not the filename. My example is here:
http://www.jps.com.au/test/

Regards
David M

Please let me know when the hidden file name problem is fixed. I am experiencing the same problem as ROYLER.

Same problem for me as with Jim and Royler, the filenames don’t show up, just the extensions. I tried all 3 versions.

Why do you use generic “” tag instead of php tag “” ??
Maybe I don’t know something, but I had to change all the tag to get the script functional, and I also have to change to .

I miss something?

Anyway a great script!

Mako’

Ok, I’ve found php setting “short tag open” and now your original script works!

Sorry for many comment…
How to inlcude your script in another .php page?

hi greg, is it possible i contact you via email ? i have this idea which i want to integrate with your directory list script together with the vlc media player web plugin, activeX, you can see it here http://www.mysoogal.com/mysoogals

what i want to do with your script is to enable the video files uploaded into that directory, to be auto enabled to be displayed with the vlc plugin automatically,

the below code is is used to change video, what i want is to be able to do this sort of thing with your script, can you please help me figure this thing out.

11th Mother – Part 1 – korean movie

i hope you understand, my email is contact@mysoogal.com
i hope to hear from you and sort this issue out.

thanks for your time
alexander a.
mysoogal.com

Hello – I am really excited by this script as I make hundereds of audio files available to people but have just been doing it the old way. However, there are a lot of folders and it’s all behind a .htaccess section. Just wondering if there is a way to:
- get .htaccess and .htpasswd not to display themselves,
- get .htaccess to run this file for every sub-directory so it doesn’t ahve to be put into every folder (we’re talking hundreds)

Thanks.

Hi Greg.

Great script.

Is it possible to ger rid of the ./ in front of the directory names – so that they are just listed with their names?

Hope you can help.

Br.
Jens

Great script, I have the same problem most have with the filename not showing, only the extension. Just rename the file index.php5 and it works perfect.
Good job and thank for sharing it.

Hi
For all those wondering why only the extension is showing and not the full filename. This script uses a feature added in PHP5.2.0 – PATHINFO_FILENAME.

To get the script to work in pre PHP5.2.0 add the following code to line 97

if(!isset($info['filename'])){
$reversed_filename = strrev( $info['basename'] );
$info['filename'] = strrev( substr( $reversed_filename, strpos( $reversed_filename, ‘.’ ) + 1 ) );
}

Hope this helps
Rob

i only see the file extensions not the filesnames :(

Hello, Not being a programmer I saw this script as a god-send for what I was doing. The only question I am asking is if there could be some way of getting the script to work for a directory with hundreds of sub folders (and sub-folders in them) so that all the contents within a chosen directory can use the one .php page (rather than copying it hundreds of times.
I tried my best with .htaccess but apart from that file showing up as well in the list – it didn’t work.
Sweet script though!!

files show up as extension only and the link is wqrong.
Folders show up as ./ only, link also wrong

This is what i was looking for…..!!!!!!!
Great job, but does anyone resolved the problem whit the name file??
Please help me, I’ll be very grateful to you for your help :-)

Sounds like i’m just echoing everyone else, but it really IS exactly what i have been searching for all evening! Thanks so much for an awesome script!

I suspect you have permission issue is your file names don’t display.

What I need is to understand the mov, avi and flv player. I’m befuddles on how it works, unless all that code is the actual player.

Help?

All the individual “files” required to make the script work are base64 encoded into strings and stored in the script itself.

Awesome script.

For a future release would it be possible to include sorting the columns by file name, date, site, date modified etc?

Hi Greg, Wanted to let you know that the script is great. I did edit it, leaving credit to you. I’d like to provide you the version that I created for PHPDL v2. Please email email me and I’ll provide it to you. Thanks.

Is there a way to exclude certain file types from show up? For example, I don’t want *.ini *.db *.jpg files to show in the directory list, but for the life of me cannot figure out how to exclude them. Any ideas?

Thanks.

Before I try I thought I’d ask: is there an easy way for the non-php skilled to easily change (increase) the overall width of the display column. I’m looking to replace a similar script that cannot handle long file names.

Additionally, can yours be used to browse non-anonymous FTP sites?

cheers

Great script – thanks. One thing, would it be possible to specify a list of files to omit from the listing? I was thinking particularly of .htaccess and password.txt files.

i try the lite edition.. simple yet brilliance css design. Needs some updates on the coding – latest php server req.., but it worth.. thanks!

really great script. exactly what i looked for. one simple file. no config. just working. was in a hurry and this was the first script i found. installed in 10 seconds :)

I just wanted to thank you for this script. It is exactly what I was looking for to use on my website. Great work.

Pretty neat script. vers2 with the embedded media player kicks ass.
Will it be possible to include in the future a function that will clean the links/filenames by replacing underscore _ with space ?

Regards

very cool. Question though, is there code that can be added to allow to “delete” a file as well? Maybe beside the “download” option?

Hey, great job with the script.

It doesn’t work for me however… I don’t get the total number of files and their size at the bottom of the listing, and the names of the files are non-existent. Their extension are there though (so I get a bunch of .flv, .m4v, .wmv…or whatever the filetype is, but no file name). Which means people get a 404 whenever they try to preview/download the file. Is this because of my setup or simply some small bugs in the code?

Thanks,
Kev

sorry about my previous comment. I got the php5 fix from above. Please delete both of my comments :) Great job again :) And thank you much for giving away such an awesome script.

thanks Greg for your job.
to hide .htaccess, .htpassword (or other files) change the line 92:

from:
if ($file != “.” && $file != “..” && $file != $this_script)

to:
if ($file != “.” && $file != “..” && $file != $this_script && $file != “.htpasswd” && $file != “.htaccess”)

Greg – thanks so much for this – nice work. Simple easy solution to a surprisingly common question :-)

all the best, Paul.

Hi,

This is GREAT – just what I was after. One question though – How do I dive the ‘Download xxxxxxx.xxx’ column more width so that it doesn’t break across two lines.

Many thanks,

Gideon

i’m going to say.. thanks a lot :D

*required

*required (will not be published)

Allowed html: <a href="">, <b>, <strong>, <em>, <i>, <strike>, <code> and <blockquote>

  • western digital rma instructions
  • mead making instructions
  • canon printer instruction manual
  • origami angel instructions
  • braiding rope instructions
  • bmw user manual
  • asus user manual
  • motorola xts 2500 user manual
  • instructions for form 8889
  • instructional strategies for english
  • shower pan installation instructions
  • instructional input
  • named collection of stored data instructions or information
  • rival roaster oven instructions
  • fec form 3x instructions
  • maximize instructional time
  • breadman user manual
  • silk screen instructions
  • boo boo bunny instructions
  • lego bus instructions
  • instructional dvd rental
  • instructions on how to play uno
  • sta-21 instruction
  • bamboo steamer instructions
  • federal tax 1040a instructions