【问题标题】:Cannot use scandir from intranet无法使用来自 Intranet 的 scandir
【发布时间】:2012-09-03 18:07:50
【问题描述】:

我正在尝试使用 scandir() 来获取目录的文件列表。

<?php
function getFileList($directory) {
    //Get the listing of the files/folders within the directory, place into an array.
    $files = scandir($directory);
    //Remove . and .. from the array.
    unset($files[0]);
    unset($files[1]);
    //Reindex array.
    $files = array_values($files);

    return $files;
}

$directory = '//192.168.1.20/is/Vendors/DavLong/Krames/';
    $files = getFileList($directory);

?>

当从我的本地计算机 (192.168.1.165) 运行时,使用此代码效果很好,但是当通过公司内部网 (192.168.1.35) 运行时,我收到以下警告,使我的脚本无法运行:

Warning: scandir(//192.168.1.20/is/Vendors/DavLong/Krames/) [function.scandir]: failed to open dir: Invalid argument in C:\Inetpub\wwwroot\DocumentPrint\index.php on line 4

Warning: scandir() [function.scandir]: (errno 22): Invalid argument in C:\Inetpub\wwwroot\DocumentPrint\index.php on line 4

Warning: array_values() [function.array-values]: The argument should be an array in C:\Inetpub\wwwroot\DocumentPrint\index.php on line 9

我可以在 windows 中运行对话框并在使用 192.168.1.35 框时输入//192.168.1.20/is/Vendors/DavLong/Krames/,它确实会在适当的位置打开 Windows 资源管理器,以便机器能够找到请求的地址。

有人可以帮助我解决我所缺少的内容,以便在本地和通过 Intranet 进行这项工作。预先感谢您提供的任何信息。

【问题讨论】:

标签: php scandir


【解决方案1】:

我不知道像这样通过网络读取文件夹,但是您不能映射网络驱动器并在该驱动器上尝试 scandir() 吗?

【讨论】:

  • 不幸的是,即使将其作为映射驱动器,它也会返回相同的警告。
猜你喜欢
  • 2016-07-09
  • 2012-08-06
  • 1970-01-01
  • 1970-01-01
  • 2020-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-31
相关资源
最近更新 更多