This article mainly introduced the CI (codeigniter) framework implementation of the image upload method, combined with the example form analysis based on the CodeIgniter call file upload class implementation of the image upload function related operation skills, the need for friends can refer to the next
In this paper, we describe the method of CodeIgniter framework to implement picture uploading. Share to everyone for your reference, as follows:
For the picture upload this cliché problem, I have to repeat this once again, because for this framework after all, some places worth their own learning and reference, this article I use the official documents to write, but some places need to be marked.
Let's take a look at the image upload. First create a view file in the "./application/views/" folder: text.php, the code is as follows:
CodeIgniter has its own very rich upload class library, below we take a look at the controller, a upload.php file in the controllers, 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 in the view upload_success.php
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!