2012-10-10 5 views
1

가능한 복제를 파일 및 디렉토리 목록을 가져 오는 방법 :
PHP list of specific files in a directory특정 디렉토리에

내 디렉토리에 거기에있는 모든 디렉토리와 파일을 나열합니다. 내가 어떻게 할 수 있니? 다음은 내 코드

if(opendir("user_files/".$uid."/")) { 
var_dump(readdir("user_files/".$uid."/")); 
} 
+1

사용을 사용하여 폴더에있는 파일을 나열하는 또 다른 방법이다 [글로브()] (http://php.net/manual/en/function. glob.php) 그것의 쉬운 –

+0

[scandir] (http://php.net/manual/en/function.scandir.php) 잘 작동 – Baba

+0

[scandir] (http://us3.php.net/manual/ko/) function.scandir.php)이 정확히 이것을합니다. –

답변

0

FilesystemIterator

$dir = __DIR__; 
$fi = new FilesystemIterator($dir, FilesystemIterator::SKIP_DOTS); 
echo "<ul>"; 
printf("<b>Total Files : %d</b>", iterator_count($fi)); 
foreach ($fi as $file) { 
    printf("<li>%s : %d</li>", $file->getFileName(), $file->getSize()); 
} 
echo "</ul>"; 
관련 문제