2011-02-16 1 views
0

PHP 스크립트를 만들어 afp 서버에 연결하고 각 파일 크기의 디렉토리 목록을 가져 오려고합니다. 서버는 우리 사무실에서 로컬이지만, 나는 afp 서버 측에서 스크립트를 만들 수 없습니다. 내 컴퓨터에서 다음과 같이 사용합니다 :PHP를 사용하여 원격 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 서버에 연결할 수 없습니다. 나는 AFP를 허용하지 않습니다 fopen을 살펴본 결과는 디렉토리 목록 허용 거라고 생각하지 않습니다

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/ 
+1

흥미로운 질문을하지만, 내가 전에 야생에서 PHP를위한 AFP 래퍼를 본 적이 없어, 그래서 난 내 숨을하지 않을 . ;) – deceze

+1

비록 SMB 래퍼를 보았습니다 ... 문제의 공유에서 smb를 사용할 수 있다면 그 것을 사용할 수 있습니다. – prodigitalson

답변

0

를 마운트 할 http://sourceforge.net/projects/afpfs-ng/를 사용, 그래서 난 그냥 AFP의 공유를 마운트 할 수 실현하고, readdir을 사용합니다. 나는 다음과 같은 사용하여 드라이브를 탑재했다 :

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

더 자세한 사항 here

0

아마 ... 내가 맥 미니에 개발하고 있어요

+0

건배, 내가 이식 할 때 이것을 사용할 것입니다. 내 발달에서 MacMini – Zeophlite