RecursiveDirectoryIterator给出异常 [英] RecursiveDirectoryIterator gives exception
问题描述
RecursiveDirectoryIterator提供意外的价值接收
RecursiveDirectoryIterator gives Unexpected Value Exeception
$path= WEB."sync_content/offer/";
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($path),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
$fn=$file->getFilename();
if($fn!='.' && $fn!='..' && !is_dir($fn)) {
$filePath = $file->getRealPath();
$zip->addFile($filePath,$fn);
}
}
错误是:
致命错误 消息为'RecursiveDirectoryIterator :: __ construct( http://localhost/base/sync_content/offer/):无法打开目录:在C:\ xampp \ htdocs \ base \ classes \ campaigns.class.php 249中未实现
fatal error Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(http://localhost/base/sync_content/offer/): failed to open dir: not implemented in C:\xampp\htdocs\base\classes\campaigns.class.php 249
推荐答案
您似乎正在使用URL(" http://localhost/ ..."),不适用于RecursiveIteratorIterator.最好将$path
设置为直接指向本地目录,例如$path = "/full/path/to/base/sync_content/offer/"
.
You seem to be accessing the local storage using a URL ("http://localhost/..."), which won't work for RecursiveIteratorIterator. You may be better off setting $path
to point directly to the local directory instead, like $path = "/full/path/to/base/sync_content/offer/"
.
这篇关于RecursiveDirectoryIterator给出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!