Welcome Guest, Not a member yet? Register   Sign In
Checking to see if there is file upload? [solved]
#2

[eluser]ywftdg[/eluser]
My code also:

Model

Code:
/////////////////////////////////////////////
    function update_mypage($id,$data)    {
        
        
            $data = array(
                        'dNickname' => $data[0],
                        'dBio' => $data[1],
                        'web' => $data[2],
                        'dBanner' => $data[3]
                );
            
        $this->db->where('designer.dDesignerId', $id);
        $this->db->update('designer', $data);
        
        
       }

Controller:
Code:
/////////////////////////////////////////////
    function mypage()    {
        $this->auth->restrict();
        
        $this->load->library('ftp');
        $this->load->library('validation');
        $this->load->library('upload');
        
        $id = $this->session->userdata('logged_user');
        
        $fields['nickname'] = 'nickname';
        $fields['bio'] = 'bio';
        $fields['web'] = 'web';
        $this->validation->set_fields($fields);

        
        if ($this->input->post('mypageupdate')) {        
        
                
                $dir = './assets/images/'.$id.'/';
                
                if (!is_dir($dir)) {
                    $theupload_path = mkdir('./assets/images/'.$id.'/', 0777);
                }
                
                //Upload Original Image
                $config['upload_path'] = $dir;
                $config['allowed_types'] = 'gif|jpg|png';
                $config['remove_spaces']  = TRUE;  
                $config['max_size'] = '10000';
                $this->upload->initialize($config);
                
            
                if (!$this->upload->do_upload())    {
                    
                    $data['error'] = $this->upload->display_errors();
                
                } else {
                
                $data = array('upload_data' => $this->upload->data());
                $file = $data['upload_data']['file_name'];
                
                $filenew = rename($dir . $file, $dir . $id.'.jpg');
                
                $data = array(
                $this->input->post('nickname'),
                $this->input->post('bio'),
                $this->input->post('web'),
                $filenew
                );
                
                // Get the newly renamed file
                $filetarget = $dir . $id.'.jpg';
                
                //Create Thumbnail _t
                $config['image_library'] = 'gd2';
                $config['source_image'] = $filetarget;
                $config['create_thumb'] = TRUE;
                $config['thumb_marker'] = '_t';
                $config['maintain_ratio'] = TRUE;
                $config['width'] = 57;
                $config['height'] = 40;
                $this->load->library('image_lib', $config);
                $this->image_lib->clear();
                $this->image_lib->initialize($config);
                $this->image_lib->resize();
                
                //Create Banner _mypage
                $config['source_image'] = $filetarget;
                $config['create_thumb'] = TRUE;
                $config['thumb_marker'] = '_mypage';
                $config['quality'] = '95';
                $config['maintain_ratio'] = TRUE;
                $config['width'] = 568;
                $config['height'] = 400;
                
                $this->load->library('image_lib', $config);
                   $this->image_lib->clear();
                $this->image_lib->initialize($config);
                $this->image_lib->resize();

                
                    
                $this->designer->update_mypage($id,$data);
                $this->session->set_flashdata('message', 'Mypage Updated!');
                
                redirect('designers/mypage');
                
            }
        }
        
        $data['query'] = $this->designer->get_designer($id);
        
        $pagedata['title'] = "Mypage Details";
        $pagedata['sectionstatus'] = $this->uri->segment(2, 0);
        $this->load->view('header_view', $pagedata);
        $this->load->view('mypage_view', $data);
        $this->load->view('_footer');
    }


Messages In This Thread
Checking to see if there is file upload? [solved] - by El Forum - 08-10-2008, 05:03 AM
Checking to see if there is file upload? [solved] - by El Forum - 08-10-2008, 05:21 AM
Checking to see if there is file upload? [solved] - by El Forum - 08-31-2008, 12:08 AM
Checking to see if there is file upload? [solved] - by El Forum - 08-31-2008, 02:52 AM
Checking to see if there is file upload? [solved] - by El Forum - 08-31-2008, 04:12 AM
Checking to see if there is file upload? [solved] - by El Forum - 06-08-2011, 09:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB