2016-05-17 74 views
0

我想要有一個過濾器,看看文件是否存在,以及有多少:我試圖拿起如下腳本:知道文件的存在等於部分名稱+擴展

$list = glob($filepath.$filenamePartial'*'.$ext); 
var_dump($list); 

解決1:

$list = glob($filepath.$FsisName.'_'.$count.'_'.'*'.$ext); 
if (count($list) <= 0){ 
     $FFileUPL = $filepath.$FsisName.'_'.$count.'_'.$FileDate.'.'.$ext; 
     $event  = move_uploaded_file($flTName, $FFileUPL); 
    }else{ 
     echo 'this file Exist: '.$FsisName.'-'.$count.'-'.$FileDate.'.'.$ext.'<br>'; 
     $event = false; 
    } 

我怎麼能retrive在iteratos名的文件? 解決2:

foreach($list as $fnames){ 
    $eFile['smg']  .= basename($fnames).'<br>'; 
} 
+0

因此,[文檔](http://php.net/manual/en/function.glob.php)沒有解釋得好嗎? –

+0

作爲一個現在的旁註還存在[StackOverflow enespañol](http://es.stackoverflow.com/) –

+0

@JayBlanchard謝謝你,我有一個更新它。 –

回答

0

解決:

$list = glob($filepath.$FsisName.'_'.$count.'_'.'*'.$ext); 
if (count($list) <= 0){ 
     $FFileUPL = $filepath.$FsisName.'_'.$count.'_'.$FileDate.'.'.$ext; 
     $event  = move_uploaded_file($flTName, $FFileUPL); 
    }else{ 
     echo 'this file Exist: '.$FsisName.'-'.$count.'-'.$FileDate.'.'.$ext.'<br>'; 
     $event = false; 
    } 
foreach($list as $fnames){ 
    $eFile['smg']  .= basename($fnames).'<br>'; 
}