업로드 할 파일 또는 업로드 할 파일을 확인하는 다른 dir이 포함 된 dir의 그룹을 반복적으로 반복하려고합니다. 지금까지 PHP의 파일 경로 및 재귀
, 나는 깊은 파일 시스템에이 개 수준을 갈 내 스크립트를 받고 있어요,하지만 난 내 함수의 범위 내 현재 전체 파일 경로를 유지하는 방법을 알아 냈하지 않은 :function getPathsinFolder($basepath = null) {
$fullpath = 'www/doc_upload/test_batch_01/';
if(isset($basepath)):
$files = scandir($fullpath . $basepath . '/');
else:
$files = scandir($fullpath);
endif;
$one = array_shift($files); // to remove . & ..
$two = array_shift($files);
foreach($files as $file):
$type = filetype($fullpath . $file);
print $file . ' is a ' . $type . '<br/>';
if($type == 'dir'):
getPathsinFolder($file);
elseif(($type == 'file')):
//uploadDocsinFolder($file);
endif;
endforeach;
}
을 그래서, 내가 getPathsinFolder
라고 부를 때마다 기본 경로가 있습니다. 내가 시작한 디렉토리의 현재 이름을 더하기 시작했습니다. 하지만 그 중간에 중간 폴더가 없습니다. 현재 전체 파일 경로를 범위로 유지하는 방법?
당신은 [를 사용할 수는 RecursiveDirectoryIterator] (http://www.php.net/manual/en/recursivedirectoryiterator.construct.php) 클래스 –