我正在尝试使用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当使用192.168.1.35框时,我可以在windows的运行对话框中输入//192.168.1.20/is/Vendors/DavLong/Krames/,它确实会在适当的位置打开Windows资源管理器,这样机器就能够找到所请求的地址。
有没有人能帮我弥补一下,让它在本地和通过内联网工作。提前感谢您可能提供的任何有关情况的信息。
发布于 2012-09-11 04:43:01
我不知道如何通过这样的网络读取文件夹,但您是否可以映射一个网络驱动器,并在该驱动器上尝试scandir()?
https://stackoverflow.com/questions/12359071
复制相似问题