PHP 버전 5.4.16을 실행하는 서버가 있고 디렉토리 내의 파일을 나열하기 위해 scandir을 사용하려고합니다. 문제가 무엇인지 파악하는 데 어려움을 겪고 있습니다. 나는 ../store/dir_to_scan과/root/store/dir_to_scan을 시도했다. 나는 또한 glob과 scandir를 모두 사용하여 아래 둘 모두를 사용할 수 없으므로 시도했다. dir_to_scan 디렉토리를 지우면/root/store 디렉토리가 열거됩니다.이 디렉토리는 내가 가장 혼란스러운 것을 발견합니다. 나는 chmod'd 폴더와 파일을 사용 권한 문제가 아닌지 확인하기 위해 777 번으로도 사용했습니다. foreach() [file] => /root/html/test.php [line] => 5)에 대해 제공된 잘못된 인수가 "Array ([type] => 2 [message] => 올바른 디렉토리 설정.php scandir() - foreach() [file]에 잘못된 인수가 제공되었습니다.
도움 주셔서 감사합니다.
디렉토리 설정
/root/html //where php script is run
/root/store/dir_to_scan //files I need to list
PHP 스크립트
<?
#$files = glob('../store/dir_to_scan/*', GLOB_BRACE);
$files = scandir("/root/store/dir_to_scan/");
foreach($files as $file) {
//do work here
if ($file === '.' || $file === '..') {
continue;
}
echo $file . "<br>";
}
print_r(error_get_last());
?>
해결합니다. :/ – user1628514