简体   繁体   English

无法从Intranet使用scandir

[英]Cannot use scandir from intranet

I am trying to use scandir() to get the list of files for a directory. 我正在尝试使用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);

?>

Using this code works great when run from my local machine (192.168.1.165) but when run through the company intranet (192.168.1.35) I get the following warnings which keep my script from running: 在本地计算机(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

I can the run dialog in windows and enter //192.168.1.20/is/Vendors/DavLong/Krames/ when using the 192.168.1.35 box and it does open Windows explorer at the proper location, so that machine is able to find the requested address. 我可以在Windows中运行对话框,并在使用192.168.1.35框时输入//192.168.1.20/is/Vendors/DavLong/Krames/ ,它的确会在适当的位置打开Windows资源管理器,以便机器能够找到所需的地址。

Can someone help me with what I'm missing to get this working locally and via the intranet. 有人可以帮我解决我所缺少的内容,以使其在本地和通过Intranet正常运行的问题。 Thank you in advance for any light that you may be able to shed on the situation. 预先感谢您对情况的了解。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM