【问题标题】:Connect to remote afp server using PHP使用 PHP 连接到远程 afp 服务器
【发布时间】:2011-02-18 09:15:20
【问题描述】:

我正在尝试制作一个 php 脚本来连接到 afp 服务器并获取目录列表(每个文件大小)。服务器在我们办公室的本地,但我无法在 afp 服务器端制作脚本。在我的机器上,我使用这样的东西:

$filesInDir = array();
$filesInMySQL = array();

if (is_dir($uploadDir)) {
    $dh = opendir($uploadDir);
    if ($dh) {
        $file = readdir($dh);

        while ($file != false) {
            $path = $uploadDir . "/" . $file;
            $type = filetype($path);

            if ($type == "file" && $file != ".DS_Store" && $file != "index.php") {
                $filesInDir[] = $file;
            }

            $file = readdir($dh);
        }

        closedir($dh);
    } else {
        echo "Can't open dir " . $uploadDir;
    }
} else {
    echo $uploadDir . " is not a folder";
}

但我无法连接到 afp 服务器。我查看了 fopen 它不允许 afp,我认为它不允许目录列表:

opendir("afp://ServerName/path/to/dir/");

Warning: opendir() [function.opendir]: Unable to find the wrapper "afp" - did you forget to enable it when you configured PHP? in...
Warning: opendir(afp://ServerName/path/to/dir/) [function.opendir]: failed to open dir: No such file or directory in...`

我不是要查看文件是否存在,而是要获取整个目录列表。最终,我还必须将文件远程复制到输出目录中。

例如。

mkdir afp://ServerName/output/output001/
cp afp://ServerName/path/to/dir/neededfile.txt afp://ServerName/output/output001/

【问题讨论】:

  • 有趣的问题,但我以前从未在野外见过 PHP 的 AFP 包装器,所以我不会屏住呼吸。 ;)
  • 我之前看过一个 SMB 包装器...如果您也可以在相关共享上使用 smb,您就可以使用它...

标签: php directory afp


【解决方案1】:

也许使用http://sourceforge.net/projects/afpfs-ng/ 来挂载它...

【讨论】:

  • 干杯,当我从我的开发 MacMini 移植时,我将使用它
【解决方案2】:

我在 Mac Mini 上进行开发,所以我意识到我可以挂载 afp 共享,然后使用 readdir。我必须使用以下方法安装驱动器:

sudo -u _www mkdir /Volumes/idisk
sudo -u _www mount_afp -i afp://<IP>/sharename/ /Volumes/idisk/

更多详情here

【讨论】:

    猜你喜欢
    • 2010-12-28
    • 1970-01-01
    • 1970-01-01
    • 2013-03-06
    • 2015-05-14
    • 2012-04-02
    • 1970-01-01
    相关资源
    最近更新 更多