Image upload not working in codeignitor

后端 未结 3 1253
萌比男神i
萌比男神i 2021-01-27 07:41

I create image upload code. this create directory first and then upload images to it.

In form I upload 3 images.

My Code is:

$dir_path = \'asset         


        
3条回答
  •  离开以前
    2021-01-27 08:21

    Read manual from here CI image upload.

    In codignator we use upload library to upload image .

    you pass youe parameter according to your requirment

               $config['upload_path'] = 'assets/images/product_images/'.$model."/";
                $config['allowed_types'] = 'gif|jpg|png';
                $config['max_size'] = '100';
                $config['max_width']  = '1024';
                $config['max_height']  = '768';
    
                $this->load->library('upload', $config);
    
                if ( ! $this->upload->do_upload())
                {
                    $error = array('error' => $this->upload->display_errors());
    
                    $this->load->view('Your View', $error);
                }
                else
                {
                    $data = array('upload_data' => $this->upload->data());
    
                    $this->load->view('Your View', $data);
                    }
    

提交回复
热议问题