|
|
|
การแสดงชื่อ file ข้อมูลต่างๆที่อยู่ใน folder รบกวนผู้รู้คับ ว่าครัยมีโค้ดที่แสดงชื่อ file ข้อมูลต่าง |
|
|
|
|
|
|
|
$path = "C:/AppServ/Apache";
function draw_tree($path) {
if ($f = opendir($path)) {
while ($elm = readdir($f)) {
if (is_dir($path . "/" . $elm) && $elm != "." && $elm != "..") {
$array[$elm] = draw_tree($path . "/" . $elm);
} else {
$array[] = $elm;
}
}
}
return $array;
}
print "<pre>";
print_r(draw_tree($path));
print "</pre>";
|
|
|
|
|
Date :
5 เม.ย. 2549 11:47:44 |
By :
kbnwizard |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
01 <?php
02
03 // ------------ lixlpixel recursive PHP functions -------------
04 // scan_directory_recursively( directory to scan, filter )
05 // expects path to directory and optional an extension to filter
06 // ------------------------------------------------------------
07 function scan_directory_recursively($directory, $filter=FALSE)
08 {
09 if(substr($directory,-1) == '/')
10 {
11 $directory = substr($directory,0,-1);
12 }
13 if(!file_exists($directory) || !is_dir($directory))
14 {
15 return FALSE;
16 }elseif(is_readable($directory))
17 {
18 $directory_list = opendir($directory);
19 while($file = readdir($directory_list))
20 {
21 if($file != '.' && $file != '..')
22 {
23 $path = $directory.'/'.$file;
24 if(is_readable($path))
25 {
26 $subdirectories = explode('/',$path);
27 if(is_dir($path))
28 {
29 $directory_tree[] = array(
30 'path' => $path,
31 'name' => end($subdirectories),
32 'kind' => 'directory',
33 'content' => scan_directory_recursively($path, $filter));
34 }elseif(is_file($path))
35 {
36 $extension = end(explode('.',end($subdirectories)));
37 if($filter === FALSE || $filter == $extension)
38 {
39 $directory_tree[] = array(
40 'path' => $path,
41 'name' => end($subdirectories),
42 'extension' => $extension,
43 'size' => filesize($path),
44 'kind' => 'file');
45 }
46 }
47 }
48 }
49 }
50 closedir($directory_list);
51 return $directory_tree;
52 }else{
53 return FALSE;
54 }
55 }
56 // ------------------------------------------------------------
57
58 ?>
|
|
|
|
|
Date :
5 เม.ย. 2549 11:50:27 |
By :
kbnwizard |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าต้องการให้อยู่ใน list box ล่ะค่ะ จะต้องทำยังไงดี
|
|
|
|
|
Date :
2009-08-08 16:02:22 |
By :
krataiss |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
01 <?php
02
03 // ------------ lixlpixel recursive PHP functions -------------
04 // scan_directory_recursively( directory to scan, filter )
05 // expects path to directory and optional an extension to filter
06 // ------------------------------------------------------------
07 function scan_directory_recursively($directory, $filter=FALSE)
08 {
09 if(substr($directory,-1) == '/')
10 {
11 $directory = substr($directory,0,-1);
12 }
13 if(!file_exists($directory) || !is_dir($directory))
14 {
15 return FALSE;
16 }elseif(is_readable($directory))
17 {
18 $directory_list = opendir($directory);
19 while($file = readdir($directory_list))
20 {
21 if($file != '.' && $file != '..')
22 {
23 $path = $directory.'/'.$file;
24 if(is_readable($path))
25 {
26 $subdirectories = explode('/',$path);
27 if(is_dir($path))
28 {
29 $directory_tree[] = array(
30 'path' => $path,
31 'name' => end($subdirectories),
32 'kind' => 'directory',
33 'content' => scan_directory_recursively($path, $filter));
34 }elseif(is_file($path))
35 {
36 $extension = end(explode('.',end($subdirectories)));
37 if($filter === FALSE || $filter == $extension)
38 {
39 $directory_tree[] = array(
40 'path' => $path,
41 'name' => end($subdirectories),
42 'extension' => $extension,
43 'size' => filesize($path),
44 'kind' => 'file');
45 }
46 }
47 }
48 }
49 }
50 closedir($directory_list);
51 return $directory_tree;
52 }else{
53 return FALSE;
54 }
55 }
56 // ------------------------------------------------------------
57
58 ?>
|
|
|
|
|
Date :
2009-10-28 12:11:21 |
By :
aimoomoo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|