在Codeigniter中通过ftp上传图像网址

时间:2020-02-15 09:19:49

标签: php codeigniter ftp

我想通过输入url上传图像,并通过ftp将其存储到数据库中,但显示错误提示

无法找到源文件。请检查您的路径。

 if($this->input->post('submit')){
            //Upload to the local server
            $config['upload_path'] = './images/';
            $config['allowed_types'] = '*';
            $this->load->library('upload', $config);


            if($this->upload->do_upload('image'))
            {

                //Get uploaded file information
                $upload_data = $this->upload->data();
                $fileName = $upload_data['file_name'];

                //File path at local server
                $source = "uploads/".$fileName;

                //Load codeigniter FTP class
                $this->load->library('ftp');

                //FTP configuration
                $ftp_config['hostname'] = 'xxxxx'; 
                $ftp_config['username'] = 'xxxxx';
                $ftp_config['password'] = 'xxxxx';
                $ftp_config['debug']    = TRUE;

                //Connect to the remote server
                $this->ftp->connect($ftp_config);

                //File upload path of remote server
                $destination = '/assets/'.$fileName;
                echo $destination;

                //Upload file to the remote server
                $this->ftp->upload($source, ".".$destination);

                //Close FTP connection
                $this->ftp->close();

                //Delete file from local server
                @unlink($source);

            }
        }

我该如何解决?

0 个答案:

没有答案