我正在尝试创建一个php脚本来连接到一个法新社服务器,并获得一个目录列表(每个文件大小)。服务器在我们办公室的本地,但我无法在法新社服务器端编写脚本。在我的机器上,我使用这样的东西:
$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,我认为它不会允许目录列表:
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/发布于 2011-02-18 09:15:20
我是在Mac Mini上开发的,所以我意识到我可以挂载afp共享,并使用readdir。我必须使用以下命令挂载驱动器:
sudo -u _www mkdir /Volumes/idisk
sudo -u _www mount_afp -i afp://<IP>/sharename/ /Volumes/idisk/更多详细信息here
发布于 2011-02-16 12:26:39
也许可以使用http://sourceforge.net/projects/afpfs-ng/来挂载它。
https://stackoverflow.com/questions/5012491
复制相似问题