php - CodeIgnitor - Image upload. -


whenever choice file browse , click upload, not work.

it codeignitor project. new in php , codeignitor.

#my coctroller name member , code below: public function profile_change_avater(){      $this->load->model('member_model');      if($this->input->post('upload'))     {         $this->member_model->do_upload();     }     $data['title'] = "choise avater";     echo "<pre>";     print_r($data['title']);     echo "</pre>"; $this->common_load_view('member/user_extended_profile_change_avater_content_view', 'members', 'profile_change_avater', $data );  }  model name member_model, code below:  public function do_upload(){      //$this->image_path = realpath(apppath .'../asset/images' );     $this->upload->initialize($config);     $config = array(         'allowed_type' => 'jpg|jpeg|gif|png',         'upload_path'  => 'image_path',              'max_size'     => '2000'     );      $this->load->library('upload', $config);     $this->upload->do_upload();      if( ! $this->upload->do_upload()){         $error = array('error'=>$this->upload->display_error());         return $error;     }     else      {         $data = array('upload_data'=> $this->upload->data());         return $data;     }   }  here code view: <p id="avatar-upload"> <?php   echo  form_open_multipart('member/profile_change_avater');     echo form_upload('userfile');     echo form_submit('upload','upload');      echo form_close();      ?> </p> 

what's wrong in code. if body me. world great.

in view

<p id="avatar-upload"> <?php   echo  form_open_multipart('member/profile_change_avater'); ?> <input type="file" name='image'> <?php    echo form_submit('upload','upload');      echo form_close();      ?> </p> 

and change if condition of profile_change_avater()

if($this->input->post())     {         $config = array(              'allowed_type' => 'jpg|jpeg|gif|png',             'upload_path'  => 'image_path',                  'max_size'     => '2000'         );          $this->load->library('upload', $config);           if( ! $this->upload->do_upload('image')){             $error = array('error'=>$this->upload->display_error());          }         else          {             $data = array('upload_data'=> $this->upload->data());          }      } 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -