Forum Moderators: coopster
$rootdirectory = "/";
$imagelist = array();
$ignoredirarray = array('secret','hidden','stats','hideme');
$ignorefilearray = array('secretimg.gif');
$URLpath=Array();
browse_images($rootdirectory,$URLpath);print ("There are ".count($imagelist)." images.");
for ($i=0;$i<count($imagelist);$i++){
print("<BR>".$imagelist[$i]);
}
function browse_images($dir_name, $URLpath){
global $imagelist;
global $ignoredirarray;
global $ignorefilearray;
print("<table border='0' cellpadding=0 cellspacing=0 width='100%'>\n");
$dir = opendir($dir_name);
while($file = readdir($dir)){
if($file!= "." && $file!= ".."){
if(is_dir($dir_name . $file)){
$found_dirs[] = $file;
}else{
$found_files[] = $file;
}
}
}
closedir($dir);
if($found_dirs){
sort($found_dirs);
for($i = 0; $i < count($found_dirs); $i++){
if($found_dirs[$i]!= "." && $found_dirs[$i]!= ".."){
if(! in_array( strtolower($found_dirs[$i]),$ignoredirarray)){
Array_push($URLpath,$found_dirs[$i]);
browse_images($dir_name . $found_dirs[$i] . "/",$URLpath);
Array_pop($URLpath);
}
}
}
}
if($found_files){
sort($found_files);
for($i = 0; $i < count($found_files); $i++){
if(! in_array( $found_files[$i],$ignorefilearray)){
$extension = preg_match('/\.(.*)$/',$found_files[$i],$out);
$extension = $out[1];
$fullpath = implode("/",$URLpath)."/".$found_files[$i];
if ($extension=='gif' ¦¦ $extension=='jpg' ¦¦ $extension=='png' ¦¦ $extension=='jpeg'){
Array_push($imagelist,$fullpath);
}
}
}
}
}
<?
$numcols = "4"; //number of pics in a column
$images = glob("dir/{*.jpg,*.gif,*.png}",GLOB_BRACE);
$count = count($images);
if(!$count) die;
$html = "<table cols=\"".$numcols."\">";
foreach($images as $key => $name){
$r = $key % $numcols;
if (!$r) $html .= "<tr>";
$html .= "<td><img width=300 src=\"".$name."\"></td>";
if($r == $numcols-1) $html .= "</tr>";
}
echo $html."</table>";
?>
haven't tested, but should work
i want to be able to list the files at this url
basically all i want to do is make a search box that will find files in that directory matching whatever is put into the search. there are not html files at all in the dir above, its only image files and sub directories
thanks again
[edited by: jatar_k at 6:49 am (utc) on May 21, 2004]
[edit reason] no specifics thanks [/edit]
[webmasterworld.com...]