WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Display list of files within current and subdirectories (recursively) showing each file as an anchored link and each directory as a category header.
Categories : Filesystem, Directories, Arrays, PHP Update Picture
Ron Poulton
Date : Dec 31st 1999
Grade : 4 of 5 (graded 4 times)
Viewed : 51172
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Ron Poulton
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Want a really simply file directory viewer? Take out the comments and it's obfuscated!

<?php
// grab a full file listing from the current and sub directories and show them as anchored
//(linked) files.

// pull a full file listing - requires the Unix 'find' and 'sort commands. 'find' will retrieve a
//list of all files from the current directory, 'sort' will sort the listing, and 'explode' will split
//all files into an array passed into $filelist.

$filelist = explode("\n",`find .|sort`);

// for each item (file) in the array...

for ($count=0;$count<count($filelist);$count++) {

// get the filename (including preceding directory, ie: ./software/gth1.0.9.tar.gz)

$filename=$filelist[$count];

// if it's not a directory, display linked

if (!is_dir($filename))
printf("<a href=\"%s\">%s</a><br>\n",$filename,$filename);

// otherwise tell the user it's a "category"

else printf("<p>Category: %s<p>\n",$filename);
}

?>



A function which places the path and name of all subdirectories into an array
Categories : PHP, Filesystem, Arrays, Directories
getDirArray(Path,Filter,Sorted): Returns an array of the files in a directory, filtered by regular expression and either sorted or randomized. Good for random pictures and graphics.
Categories : PHP, Filesystem, Directories
Listing the 10 most recently updated files in a given dir by using last- modified variable and printing to html with link to the file
Categories : PHP, Directories, Filesystem
Single-file PHP news system with automatic folder structure creation
Categories : PHP, Filesystem, Arrays
Grab images from one or more URLs and save them to a specified local directory.
Categories : PHP, Filesystem, Strings, Arrays
Extended Get File List Function
Categories : PHP, Filesystem, Search, Directories
Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
Categories : PHP, Directories, Variables, Arrays
PHP4 DirectoryIterator Class
Categories : PHP, PHP Classes, Filesystem, Directories
Using PHP to Delete a directory with all sub directories and files using FTP
Categories : PHP, FTP, Directories, Filesystem
This script will read all images from a folder and read the files into an array. It uses rand() to get a random number. It will display a random image from the image folder given.
Categories : PHP, Arrays, Graphics, Filesystem
Directory Viewer, Directory Content Viewer, Directory Structure to HTML. This code will basically create a complete set of HTMLs to let a user navigate through any directory you want. Excellent code for large file sharing pages.
Categories : Directories, Filesystem, PHP
Directory viewer, customize how you display the file structure, easy to understand. Found out about PHP 3 days ago, and this is my first prog.
Categories : HTML and PHP, Complete Programs, Directories, Filesystem, PHP
Compare two texts and display a block of text with the differences between them.
Categories : PHP, PHP Classes, Filesystem, Strings, Arrays
Filling an array with files from any given directory. This example is for the current PHP script's directory.
Categories : PHP, Arrays, Filesystem
Open directory and File download
Categories : PHP, Filesystem, Directories, HTML and PHP
 Ronny Vaardal wrote : 403
HI.. nice script.. Just what I was looking for.

Now what I did, was this... :)

I placed a symbolic directory as a subdirectory of the 
html-directory, that points to my mounted mp3 directory 
located in the ftp directory (phju.. :) Then, I modifed 
your script a bit...

At the top, I added a chdir("./mp3"); to go into this 
symbolic directory.
Then I made a str_replace in the $filelist to remove the 
beginning "./" on each file. Looks like this now:

$filelist = explode("\n", str_replace("./","",`find .|sort`));

further on the anchor part looks like this, to point the 
browser towards the ftp, and not the http:

printf("&lt;dd&gt;&lt;a href=\"ftp://ftp.domain.com/mp3/%
s\"&gt;%s&lt;/a&gt;&lt;/dd&gt;\n",$filename,$filename);

So with a tiny modification, I can now list my ftp server`s 
mp3 catalog with php, and make a list of anchors on a 
http page. I`m proud since this is one of my first scripts.
Next I will do an individually download/counter for each 
file, and a top20 downloaded page :)

All of this to be my "computer gathering" way of sharing 
what I got :)

And again.. thnx. man! Your a life saver I guess :)
 
 saif slatewala wrote : 1043
hi thks a lot awesome script ... save me some time ;)
 
 lucas seiden wrote :1638
hm this dosent work for me. i just copied it to try it out for the first time and i get a security warning. 

"Warning: shell_exec() has been disabled for security reasons in /www/htdocs/w006ecb7/listfiles.php on line 18"

line 18 seems to be the explode funtion one. is there an alternative to this?