如何从ftp服务器下载到在VPS中托管codeigniter站点的本地计算机

时间:2017-12-11 04:11:21

标签: php ftp codeigniter-2

我在AWS中托管了一个codeigniter网站,该网站工作正常,与ftp服务器的连接也很好。

这是我的ftp类;

public function download_ftp($file_name) {
    $this->load->library('ftp');

    $config['hostname'] = '213.62.21.2';
    $config['username'] = 'Admin';
    $config['password'] = 'admin';
    $config['port'] = 21;
    $config['passive'] = FALSE;
    $config['debug'] = TRUE;

    $this->ftp->connect($config);

    $found_file = FALSE;
    $files = $this->ftp->list_files();
    var_dump($files);
    if (count($files) > 0) {
        foreach ($files as $f) {
            if ($f == './' . $file_name) {
                $found_file = TRUE;
                break;
            }
        }
    }

    if ($found_file) {

        echo '<script type="text/javascript">
    alert("Click OK to download file. You will be notified when the download is completed. Dont refresh the page until");
        </script>';

        $result = $this->ftp->download($file_name, 'C:/new/ftp/' . $file_name);
        if ($result == FALSE) {
            echo 'file not downloaded';
        }

'C:/ new / ftp /'是本地目录,即要下载的文件。

此代码将文件下载到访问网站的客户端的托管服务器。

如何更改路径以便将文件下载到clent机器?

0 个答案:

没有答案
相关问题