Welcome Guest, Not a member yet? Register   Sign In
Update Image
#1

(This post was last modified: 11-13-2021, 05:57 AM by jreklund.)

Hey friend i cannot update the user image. it overwrites the old image.
please any hint regarding this problem?
thanks Smile
PHP Code:
public function edit($id=""){
$this->rbac->check_operation_access(); // Check auth

        if($this->input->post('submit')){
                $this->form_validation->set_rules('name''Name''trim|required|min_length[5]');
                $this->form_validation->set_rules('surname''Surname''trim|required');
                
                
if ($this->form_validation->run() == FALSE) {
                    $data = array(
                        'errors' => validation_errors()
                    );
                    $this->session->set_flashdata('errors'$data['errors']);
                    redirect(base_url('users/edit/'$id['user_id']));

                } else {

                    //$image = null;

                    if ($_FILES['image_thumb']['name']){

                        $config['upload_path']          './uploads/user_image/';
                        $config['allowed_types']        'gif|jpg|png|jpeg|JPEG|GIF|JPG|PNG';
                        $config['max_size']            "1024";
                        $config['max_width']            "*";
                        $config['max_height']          "*";
                        $config['encrypt_name']        TRUE;
                        $this->upload->initialize($config);
                        $this->load->library('upload'$config);
                        if ( ! $this->upload->do_upload('image_thumb')){

                            $this->session->set_userdata(array('errors'=> $this->upload->display_errors()));
                            redirect(base_url('users/edit/'.$id['user_id']));
                        
                        
} else {
                            $image =$this->upload->data();
                            $image_url "uploads/user_image/".$image['file_name'];

                            //delete old image
                            $old_image $this->input->post('old_image');
                            $old_file_thumb =  substr($old_imagestrrpos($old_image'/') + 1);
                            @unlink(FCPATH 'uploads/user_image/' $old_file_thumb);

                        }
                    }

                    $old_image $this->input->post('old_image');

                    $data = array(
                        'image'        => (!empty($image_url) ? $image_url $old_image), 
Reply


Messages In This Thread
Update Image - by pou_to_ksereis - 11-06-2021, 09:46 AM
RE: Update Image - by kenjis - 11-13-2021, 12:13 AM
RE: Update Image - by InsiteFX - 11-13-2021, 01:44 AM
RE: Update Image - by pou_to_ksereis - 11-15-2021, 12:41 AM
RE: Update Image - by InsiteFX - 11-15-2021, 02:33 AM
RE: Update Image - by pou_to_ksereis - 11-15-2021, 05:45 AM
RE: Update Image - by kenjis - 11-19-2021, 04:30 AM
RE: Update Image - by pou_to_ksereis - 11-23-2021, 03:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB