【问题标题】:How can I upload the filename and filepath of the image I uploaded inside "upload" folder using CodeIgniter?如何使用 CodeIgniter 上传我在“上传”文件夹中上传的图像的文件名和文件路径?
【发布时间】:2016-11-30 21:27:23
【问题描述】:

这是我的控制器。

 function upload_file() { 
                $config['upload_path']          = './upload/';
                $config['allowed_types']        = 'iso|dmg|zip|rar|doc|docx|xls|xlsx|ppt|pptx|csv|ods|odt|odp|pdf|rtf|sxc|sxi|txt|psd|exe|avi|mpeg|mp3|mp4|3gp|gif|jpg|jpeg|png';
                $config['max_size']             = 3072;
                $config['max_width']            = 1024;
                $config['max_height']           = 768;
                $this->upload->initialize($config);
                $this->load->library('upload', $config);

                if (!$this->upload->do_upload('userfile'))
                {
                        $error = array('error' => $this->upload->display_errors());
                        $this->load->view('header');
                        $this->load->view('file', $error);
                        $this->load->view('footer');
                }
                else
                {
                        $data = array('upload_data' => $this->upload->data()); 
                        $this->load->view('header');
                        $this->load->view('file', $data);
                        $this->load->view('footer');
                }
    }

如何制作模型?我要上传上传图片的文件名和路径。

【问题讨论】:

标签: php codeigniter model-view-controller


【解决方案1】:

要显示图片,可以如下使用:

<img src="<?php echo base_url('upload/' . $image_name); ?>" />

【讨论】:

    猜你喜欢
    • 2012-04-22
    • 2018-02-22
    • 2014-01-06
    • 2016-03-11
    • 2020-08-01
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    • 2011-04-08
    相关资源
    最近更新 更多