如何使用PHP列出Windows共享的内容?

$SearchFolder = "\\\\192.168.1.100\\pdfoutput\\";

if (is_dir($SearchFolder))
{
    if ($Directory = opendir($SearchFolder))
    {
        while (($File = readdir($Directory)) !== false)
        {
            if(filetype($SearchFolder.$File) == "file")
            {
                $this->Attachments[] = new Attachment($SearchFolder.$File);
            }
        }
        closedir($Directory);
    }
}

print(opendir($searchfolder));出现以下错误:
警告:
opendir(\192.168.1.100\pdfoutput)
[function.opendir]:无法打开
目录:没有错误
C:\users\gary\webserver\quickmail\maildetails.php
在线227
这不是预期的效果。有什么想法吗?

最佳答案

http://uk3.php.net/function.opendir查看opendir函数的用户注释。看来有些信息对你有帮助。具体来说,daverandom的这段代码可以解决您的问题:

<?php
// Define the parameters for the shell command
$location = "\\servername\sharename";
$user = "USERNAME";
$pass = "PASSWORD";
$letter = "Z";

// Map the drive
system("net use ".$letter.": \"".$location."\" ".$pass." /user:".$user." /persistent:no>nul 2>&1");

// Open the directory
$dir = opendir($letter.":/an/example/path")
?>

09-13 01:32