The CI (CodeIgniter) framework implements the Image Upload method, cicodeigniter
This document describes how to upload images using the CodeIgniter framework. We will share this with you for your reference. The details are as follows:
I have to repeat the conventional problem of uploading images once again, because the framework is worth learning and learning for some places. I wrote this article using official documents, however, in some cases, you need to mark it.
Next let's take a look at uploading images. First, create a View File text. php In the "./application/views/" folder. The Code is as follows:
Codeigniter has its own rich upload class library. Let's take a look at the Controller. In the Controller, an Upload. php file, the Code is as follows:
class Upload extends CI_Controller{ public function __construct(){ parent::__construct(); $this->load->helper("form","url"); } public function index(){ $this->load->view('test',array("error"=>'')); } public function do_upload(){ $config['upload_path']='./uploads/'; $config['allowed_types']='gif|jpg|png'; $config['max_size']=100; $config['max_width']=1024; $config['max_height']=768; $this->load->library('upload',$config); if(!$this->upload->do_upload('userfile')){ $error=array('error'=>$this->upload->display_errors()); $this->load->view('test',$error); }else{ $data=array('upload_data'=>$this->upload->data()); $this->load->view('upload_success',$data); } }}
Next, create another file upload_success.php in the view.