Jump to content


Folders


2 replies to this topic

#1 N00bie_XL

    Young Padawan

  • Members
  • Pip
  • 4 posts
  • Location:The Netherlands

Posted 26 May 2006 - 10:13 AM

<?php
include ('config.php');
while (false !== ($file = readdir($handle))) {
   	if ($file != "." && $file != "..") {
   		$arr_img[] = $file;
   	}
}
$i = 0;

foreach($arr_img as $var_img) {
	if($var_img != "") {
echo <<< HTML
<a href="./test/$arr_img[$i]"><img src="./test/$var_img" width="10%" height="10%"/></a> 
HTML;
	}
$i++;
}
?>

This code let me show my images as a link.
But now I need to show my folders as a link but how?
The only thing I can make is a link to my files, but thats
not what I need.
So lets say I got a main folder called test and the
subfolders test2 and test3.
How do I show test2 and test3 as a link?

Thx for any help!

Edited by N00bie_XL, 26 May 2006 - 10:14 AM.


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 26 May 2006 - 12:18 PM

You would show the folder same way you would show the file.
http://php.net/manua...f.dir.php#60982 <- directory/subdirectory lister

#3 AvengeX

    Young Padawan

  • Members
  • Pip
  • 50 posts
  • Gender:Male
  • Location:Kingston upon Thames, UK
  • Interests:d&amp;b

Posted 27 May 2006 - 03:11 AM

I must also stress the importance of using the functions:

is_file
is_dir

Because they can come in handy when you're echoing things for files. If you're linking a directory in an image script, it wouldn't really.. work.. :biggrin:





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users