【发布时间】: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 进行这项工作。预先感谢您提供的任何信息。
【问题讨论】:
-
你检查过这个过去的帖子吗?它可能会有所帮助。 stackoverflow.com/questions/1153824/…