我嘗試在/images
目錄上的所有文件運行,我得到斷開,當我到達構造部分的目錄是在同一個目錄中我的PHP文件:FilesystemIterator不工作
$it = new FilesystemIterator('./images/');
foreach ($it as $fileinfo) {
echo $fileinfo->getFilename() . "\n";
}
我看到的錯誤是:
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'FilesystemIterator::__construct(/images/,/images/): The system cannot find the file specified. (code: 2)' in D:\wamp\www\MyHome2\php\images.php:9
文件系統路徑應該是從文件系統根目錄;懷疑你的目錄是從你的網絡服務器htdocs根 –
我現在明白爲什麼它不工作我的PHP文件是在/ php目錄我需要做的事情我需要這樣做../images :) – Canttouchit