FTPClient::make_collection PHP Method

make_collection() public method

public make_collection ( $path )
    public function make_collection($path)
    {
        $path = $this->get_encoded_path($path);
        if (false === ($conn = $this->get_connection_handle())) {
            throw new Exception("Could not connect to FTP server.");
        }
        if ('/' == $path[0]) {
            $path = substr($path, 1);
        }
        if ('/' == substr($path, -1)) {
            $path = substr($path, 0, -1);
        }
        $path_parts = explode('/', $path);
        for ($i = 0; $i < sizeof($path_parts) - 1; $i++) {
            if (false === @ftp_chdir($conn, $path_parts[$i])) {
                $this->throw_exception("Could not change to directory `{$path_parts[$i]}'.");
            }
        }
        $label = $path_parts[sizeof($path_parts) - 1];
        if (false === @ftp_mkdir($conn, $label)) {
            $this->throw_exception("Could not make directory `{$label}'.");
        }
        @ftp_close($conn);
        return true;
    }

Usage Example

コード例 #1
0
ファイル: ftp.php プロジェクト: aprilchild/aprilchild
 protected function createCollectionResource($ticket, $path, $label)
 {
     if (false === ($session = $this->retrieveSessionData($ticket))) {
         throw new Exception('Could not load FTP resources. Session error.');
     }
     $new_path = $path . '/' . $label;
     $ftp = new FTPClient($session[0], $session[1], $session[2]);
     return $ftp->make_collection($new_path);
 }