簡體   English   中英

使用PHP連接到遠程AFP服務器

[英]Connect to remote afp server using PHP

我正在嘗試制作一個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/

也許使用http://sourceforge.net/projects/afpfs-ng/來安裝它...

我在Mac Mini上進行開發,因此我意識到我可以掛載afp共享,並使用readdir。 我必須使用以下方法安裝驅動器:

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

這里的更多細節

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM