2012-03-24 158 views
0

我正在使用以下內容來嘗試列出客戶目錄中的所有文件。它應該與從在GET舉行的前一頁的客戶ID的路​​徑來替代$的customerID,而是我收到錯誤消息:使用RecursiveDirectoryIterator時找不到文件

500 - RecursiveDirectoryIterator :: __結構(./客戶-files/$ customerID,。/ customer-files/$ customerID)[recursivedireiteiterator .-- construct]:系統找不到指定的 文件。 (代碼:2)

<?php 
$customerID = $_GET['customerID']; 
echo '<h1>'; 
echo $customerID; 
echo '</h1>'; 
?> 


<?php 
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('./customer-files/$customerID')) as $filename) 
{ 
    echo '<p>'; 
    echo $filename->getFilename(); 

    echo '</p>'; 
} 
?> 

回答

1

您使用在你的$的customerID變量單引號,所以你要麼必須Concat的,或者切換到雙引號,試試這個:

foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('./customer-files/' . $customerID)) as $filename) 
+0

謝謝! ,現在完美的工作:-) – 2012-03-24 20:34:17

+0

不錯。喜歡ez修復。儘可能接受。 – 2012-03-24 20:37:28

相關問題