Whenever I choice file from browse and click upload, it does not work.
It is codeignitor project. I am new in php and codeignitor.
#My coctroller name is member and code is below:
public function profile_change_avater(){
$this->load->model('member_model');
if($this->input->post('upload'))
{
$this->member_model->do_upload();
}
$data['title'] = "Choise your 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 );
}
My model name is member_model, code is 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 is the 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 my code. If any body help me. It world be great.