2013-12-16 2 views
0
foreach (new DirectoryIterator($tempFilesPath) as $fileData) 
{ 
$fileName   = $fileData->getFileName(); 
$fileModifiedTime = $fileData->getMTime(); 
} 

디렉토리에 .exe, .site 같은 파일이 포함되어있어 파일 이름을 얻지 못하고 있습니까?파일 디렉토리의 확장자를 필터링하는 방법

+0

가능한 중복 [기본 이름을 해달라고 .extension 파일을 탈출하는 방법 (http://stackoverflow.com/questions/20607045/how-to-escape- 확장 파일 -dont-have-basename) –

답변

0

확인이 전체 ..

http://net.tutsplus.com/tutorials/php/quick-tip-loop-through-folders-with-phps-glob/

예를 사용할 수있다 : 우리는 인쇄 하위 폴더 이름을하고자하는 경우 , 우리는 GLOB_ONLYDIR을 사용할 수 보기 plaincopy는 clipboardprint 수 있나요? 인쇄 할

foreach(glob('userImages/*/TN/*', GLOB_ONLYDIR) as $image) 
{ 
    echo "Filename: " . $image . "<br />";  
} 

:

Filename: userImages/username2/TN/subfolder 
0

시도를

$it = new DirectoryIterator(dirname(__FILE__)); 
foreach ($it as $fileinfo) { 
    if (!$fileinfo->isDot()) 
    var_dump($fileinfo->getFilename()); 
} 

도트 디렉토리는 isDot() 방법을 사용하여 루프 필터링 할 수 있습니다.

$it = new FilesystemIterator(dirname(__FILE__)); 
foreach ($it as $fileinfo) { 
    echo $fileinfo->getFilename() . "\n"; 
} 

FilesystemIterator

도트 디렉토리를 건너 뜁니다의

관련 문제