• Upload a file in Codeigniter framework

    Date Posted: 09-29-2016
    Author: CEBUFREELANCER

    
    function upload() {
    
            $config['upload_path'] = "uploads/";
            $config['allowed_types'] = "gif|jpg|jpeg|png";  
            $config['max_size'] = "5000";
            $config['max_width'] = "1907";
            $config['max_height'] = "1280";
            $config['overwrite'] = "FALSE";
            
            
            $detail = $this->input->post('detail');
    
    
            $new_name = time() . "-";
            $config['file_name'] = $new_name;
    
            $this->load->library('upload', $config);
    
            if (!$this->upload->do_upload()) {
                echo $this->upload->display_errors();
            } else {
                $finfo = $this->upload->data();
                $this->create_thumbnail($finfo['file_name']);
    
                $data['thumbnail_name'] = $finfo['raw_name'] . '_thumb' . $finfo['file_ext'];
    
                $this->upload_model->upload( $data['thumbnail_name'], $finfo ['file_name'], $finfo ['client_name'], $finfo ['full_path']);
                redirect('/');
            }
        }
     
     

Advertisement