YesYo.com MintState Forums
뒤로    YesYo.com MintState BBS > Tech > PHP
검색
멤버이름    오토
비밀번호 
 

특정 디렉토리의 하위파일 목록 가져오기

페이지 정보

작성자 MintState 댓글 0건 조회 8,382회 작성일 17-02-21 11:32

본문

특정 디렉토리의 하위파일 목록 가져오기

<?php
// 폴더명 지정
$dir = "/home/www/foo/test_folder_name";
 
// 핸들 획득
$handle  = opendir($dir);
 
$files = array();
 
// 디렉터리에 포함된 파일을 저장한다.
while (false !== ($filename = readdir($handle))) {
    if($filename == "." || $filename == ".."){
        continue;
    }
 
    // 파일인 경우만 목록에 추가한다.
    if(is_file($dir . "/" . $filename)){
        $files[] = $filename;
    }
}
 
// 핸들 해제 
closedir($handle);
 
// 정렬, 역순으로 정렬하려면 rsort 사용
sort($files);
 
// 파일명을 출력한다.
foreach ($files as $f) {
    echo $f;
    echo "<br />";
} 
?>

댓글목록

등록된 댓글이 없습니다.

Total 165건 7 페이지
게시물 검색
모바일 버전으로 보기
CopyRight ©2004 - 2024, YesYo.com MintState. ™