elFinderVolumeFTP::ftp_download_files PHP Method

ftp_download_files() private method

Downloads specified files from remote directory if there is a directory among files it is downloaded recursively (omitting symbolic links).
private ftp_download_files ( $remote_directory, array $files, $dest_local_directory ) : boolean
$remote_directory string remote FTP path to a source directory to download from.
$files array list of files to download from remote directory.
$dest_local_directory string destination folder to store downloaded files.
return boolean true on success and false on failure.
    private function ftp_download_files($remote_directory, array $files, $dest_local_directory)
    {
        $contents = $this->ftp_scan_dir($remote_directory, $files);
        if (!isset($contents)) {
            $this->setError(elFinder::ERROR_FTP_DOWNLOAD_FILE, $remote_directory);
            return false;
        }
        $remoteDirLen = strlen($remote_directory);
        foreach ($contents as $item) {
            $relative_path = substr($item['path'], $remoteDirLen);
            $local_path = $dest_local_directory . DIRECTORY_SEPARATOR . $relative_path;
            switch ($item['type']) {
                case 'd':
                    $success = mkdir($local_path);
                    break;
                case 'f':
                    $success = ftp_get($this->connect, $local_path, $item['path'], FTP_BINARY);
                    break;
                default:
                    $success = true;
            }
            if (!$success) {
                $this->setError(elFinder::ERROR_FTP_DOWNLOAD_FILE, $remote_directory);
                return false;
            }
        }
        return true;
    }