我正在尝试使用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资源管理器,这样机器就可以找到请求的地址。
有人能帮我解决我缺少的东西吗?让它在本地和通过内部网工作。提前感谢您对情况的了解。
我不知道如何像这样通过网络读取文件夹,但你不可能映射一个网络驱动器并在该驱动器上尝试scandir()吗?