php - image upload in codeigniter -


i trying upload image in following code: controller:

public function do_register()     {         $this->load->library('form_validation');          $this->form_validation->set_rules('uname', 'username', 'required|min_length[4]|max_length[15]');         $this->form_validation->set_rules('email', 'email', 'required|valid_email');         $this->form_validation->set_rules('pass', 'password', 'required|min_length[4]');         $this->form_validation->set_rules('address', 'details', 'required|min_length[4]');         if($this->form_validation->run() == false)         {             $this->load->view('login_view');         }         else         {             $path = $_files['image']['name'];             $imgext=strtolower(strrchr($path,'.'));             $imgname= $this->generaterandomstring().$imgext;             if($path!='')             {                 $im= $this->config->item('base_url').'/uploads'.'/'.$imgname;                 $x=$this->do_upload($imgname);                 $data['img']=$im;             }              $this->search_model->register_user($data['img']);             $this->load->view('register_view');          }     }        function generaterandomstring()     {         $characters = '0123456789abcdefghijklmnopqrstuvwxyz';         $randomstring = '';         ($i = 0; $i < 8; $i++) {             $randomstring .= $characters[rand(0, strlen($characters) - 1)];         }         return $randomstring;     }        function do_upload($img)     {         $config['upload_path'] = './uploads/';         $config['allowed_types'] = 'gif|jpg|png';          $config['max_size'] = '1024 ';          $config['file_name'] = $img;         $this->load->library('upload',$config);          if ( ! $this->upload->do_upload('image'))          {             $error = array('error' => $this->upload->display_errors());              print_r($error);              die();             register("search/register");         }         else         {             $data = array('upload_data' => $this->upload->data());             $this->load->view(register_view,$data);             return $data;         }         return;     } 

i upload image size greater 1 mb, registration did not error messsage . when print error using code print_r($error) ,

error message displayed "the uploaded file exceeds maximum allowed size in php configuration file."

how solve issue?

sounds need increase post_max_size in php.ini. increased upload_max_filesize

in php.ini

set

post_max_size = 256m// according requirment upload_max_filesize 128m 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -