Upload multiple files in CodeIgniter

You can Upload any number of Files..

$config['upload_path'] = 'upload/Main_category_product/';
$path=$config['upload_path'];
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_size'] = '1024';
$config['max_width'] = '1920';
$config['max_height'] = '1280';
$this->load->library('upload', $config);

foreach ($_FILES as $fieldname => $fileObject)  //fieldname is the form field name
{
    if (!empty($fileObject['name']))
    {
        $this->upload->initialize($config);
        if (!$this->upload->do_upload($fieldname))
        {
            $errors = $this->upload->display_errors();
            flashMsg($errors);
        }
        else
        {
             // Code After Files Upload Success GOES HERE
        }
    }
}

Leave a Comment