[Solved] How to Upload Image files Using Codeigniter? [closed]


Here is an example. Hope this would help you 🙂

in your controller. lets say upload.php

public function upload() {
    if($this->input->post('upload')) {

        $config['upload_path'] = APPPATH . 'your upload folder name here/'; 
        $config['file_name'] = filename_here;
        $config['overwrite'] = TRUE;
        $config["allowed_types"] = 'jpg|jpeg|png|gif';
        $config["max_size"] = 1024;
        $config["max_width"] = 400;
        $config["max_height"] = 400;
        $this->load->library('upload', $config);

        if(!$this->upload->do_upload()) {               
            $this->data['error'] = $this->upload->display_errors();
        } else {
            //success                                      
        }  
    }
}

Then in your view

<?php echo form_open_multipart('upload'); ?>    
<?php echo form_upload('userfile'); ?><br />
<?php echo form_submit('upload', 'Upload');?>    
<?php echo form_close(); ?>

1

solved How to Upload Image files Using Codeigniter? [closed]