首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用PHP连接到远程afp服务器

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

Stack Overflow用户
提问于 2011-02-16 12:17:12
回答 2查看 2K关注 0票数 0

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

代码语言:javascript
复制
$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";
}

但我无法连接到法新社服务器。我已经调查了fopen它不允许afp,我认为它不会允许目录列表:

代码语言:javascript
复制
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...`

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

例如:

代码语言:javascript
复制
mkdir afp://ServerName/output/output001/
cp afp://ServerName/path/to/dir/neededfile.txt afp://ServerName/output/output001/
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-02-18 09:15:20

我是在Mac Mini上开发的,所以我意识到我可以挂载afp共享,并使用readdir。我必须使用以下命令挂载驱动器:

代码语言:javascript
复制
sudo -u _www mkdir /Volumes/idisk
sudo -u _www mount_afp -i afp://<IP>/sharename/ /Volumes/idisk/

更多详细信息here

票数 0
EN

Stack Overflow用户

发布于 2011-02-16 12:26:39

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5012491

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档