DirectoryIterator 在网络附加存储上失败

DirectoryIterator fails on Network Attached Storage

这是所有迭代器中最简单的:

<!DOCTYPE html>
<html>

<head>
 <?php
  $it = new DirectoryIterator("c:");

  foreach($it as $file) 
  {
    if (!$it->isDot()) 
    {
      echo $file . "\n";
    }
  }
 ?>
</head>
<body>
 Test of directory iterator
</html>

这在我的本地 C: 驱动器上工作正常,但如果我将它更改为我的网络附加存储驱动器 (Z:),它会失败:

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'DirectoryIterator::__construct(z:,z:): The system cannot find the path specified. (code: 3)' in B:\public_html\test\test.php on line 8 ( ! ) UnexpectedValueException: DirectoryIterator::__construct(z:,z:): The system cannot find the path specified. (code: 3) in B:\public_html\test\test.php on line 8

NAS在其他方面都很好。

LocalHost 是一个 Apache WAMP PHP 5

查看您收到的错误消息:

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'DirectoryIterator::__construct(z:,z:): The system cannot find the path specified. (code: 3)' in B:\public_html\test\test.php on line 8 ( ! ) UnexpectedValueException: DirectoryIterator::__construct(z:,z:): The system cannot find the path specified. (code: 3) in B:\public_html\test\test.php on line 8

因此您必须将 c: 更改为 B: