Upload multiple files in CodeIgniter

后端 未结 7 1016
谎友^
谎友^ 2020-11-27 18:35

In my CodeIgniter project I\'m uploading files during the project creation. Here\'s the uploading function:

function uploadFiles(){

     $this->load->         


        
7条回答
  •  借酒劲吻你
    2020-11-27 19:13

    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
            }
        }
    }
    

提交回复
热议问题