1

我想上传 2 个带有 2 个配置部分的文件,但第一个文件不起作用,第二个文件对我有好处。我怎样才能在这段代码中找到问题。

请帮我。这是我的代码:

$this->load->library('upload');

    $config['upload_path']   = './uploads/images/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size']      = '200';
    $config['max_width']     = '200';
    $config['max_height']    = '200';
    $config['file_name']     = time();

    $this->upload->initialize($config); // Important
    if ($this->upload->do_upload('logo')) { 

        $logo = $this->upload->data(); 

    } elseif ($this->input->post('logo')) { 

        $logo['file_name'] =  $this->input->post('logo');

    } else {
        $logo['file_name'] = '';    
    }

    //===================================================

    $config['upload_path']   = './uploads/images/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size']      = '200';
    $config['max_width']     = '950';
    $config['max_height']    = '250';
    $config['file_name']     = time();

    $this->upload->initialize($config); // Important
    if ($this->upload->do_upload('header')) { 

        $header = $this->upload->data(); 

    } elseif($this->input->post('header')) {

        $header['file_name'] =  $this->input->post('header');   

    } else { 
        $header['file_name'] = ''; 
    }
4

0 回答 0