使用 PHP 连接到远程 afp 服务器

发布于 2024-10-18 03:36:19 字数 1331 浏览 7 评论 0原文

我正在尝试制作一个 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/

I'm trying to make a php script to connect to an afp server and get a directory listing (with each file size). The server is local in our office, but I'm unable to just make a script on the afp server side. On my machine, I use something like this:

$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";
}

But I can't connect to the afp server. I've looked into fopen it doesn't allow afp, and I don't think it'd allow directory listing:

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...`

I'm not looking to see if a file exists, but to get the entire directory listing. Eventually I'll also have to remotely copy files into an output directory.

eg.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

骷髅 2024-10-25 03:36:19

也许使用 http://sourceforge.net/projects/afpfs-ng/ 来安装它。 ..

山人契 2024-10-25 03:36:19

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

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

更多详细信息此处

I'm developing on an Mac Mini, so I realised I could just mount the afp share, and use readdir. I had to mount the drive using the following:

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

Further details here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文