LAMP

PHP 디렉토리안에 파일 리스트 가져오기

영은파더♥ 2017. 6. 1. 11:26
728x90

PHP 디렉토리안에 파일 리스트 가져오기


특정 디렉토리안에 파일리스트를 가져오는 예제소스입니다.

$DIR_PATH = "/var/www/html/";

if(is_dir($DIR_PATH)) {

if($dh = opendir($DIR_PATH)) {

while(($file = readdir($dh)) !== false) {

if ($file == "." || $file == "..") {

continue;

}

$_file = $DIR_PATH.$file;

if(is_file($_file)) {

echo "filename: ".$_file."<br>";

}

}

closedir($dh);

}

}


728x90
반응형