This article mainly introduces the CI (CodeIgniter) framework to implement image upload methods. combined with the instance form, it analyzes the related operation skills of calling the file upload class based on CodeIgniter to implement the image upload function, for more information about how to use the CI (CodeIgniter) framework to upload images, combined with examples, this article analyzes the related operation skills for calling the file upload class based on CodeIgniter to implement the image upload function. For more information, see
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:
Upload Form
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.
Upload Form Your file was successfully uploaded!
The above is a detailed description of how the CI framework uploads images. For more information, see other related articles in the first PHP community!