file directory (tree) tutorails

A

Anonymous

Guest
hi, im wishing to create a image gallery myself, i want it dynamic with no database and so it shows the files from the directory and so on..

but i have no idea on how to access and read dir's and stuff, any one know of any good sites to look at for help?
 
This is not written by me!!! User note in php manual

This is a recursive algorithm for dumping the contents of any directory into a multidimensional array. Files are indexed numerically and directories are indexed associatively. You can then use whatever algorithm you want to view the array.

Code:
<?php
function recursive_ls($listing, $directory, $count)
{
$dummy = $count;
if ($handle = opendir($directory)) {
while ($file = readdir($handle)) {
        if ($file=='.' || $file=='..') continue; 
else if ($h = @opendir($directory.$file."/")) {
closedir($h);
$count = -1;
$listing["$file"] = array(); 
recursive_ls(&$listing["$file"], $directory.$file."/", $count + 1); }
else {  $listing[$dummy] = $file;
         $dummy = $dummy + 1;}
}}
closedir($handle);
return ($listing);
      }
//Example call
$testlist = recursive_ls(array(), "/home/nolan/tarballs/", 0);
?>
 
php-punk said:
i want it dynamic with no database and so it shows the files from the directory and so on..

Why no database? Just don't feel like it? How are you planning on storing metadata (e.g. author, comments, etc.)?
 
i recommend to you use DB for storing path to images and short info.
minus for your idea: if images too big, the process of reading and parsing of images it's too slow procedure
 
Back
Top