Codeigniter上传助手 - is_image返回false。

时间:2018-03-22 11:26:38

标签: codeigniter-3

我正在尝试上传图片。我的代码与codeigniter中的文档完全相同,但是当我var_dump die(var_dump($this->upload->data('')));时,我得到以下内容:

(数组)[14个元素] file_name :(字符串) file_type :(字符串) file_path :(字符串) full_path :(字符串) raw_name :(字符串) orig_name :(字符串) client_name :(字符串) file_ext :(字符串) file_size:(null)NULL is_image :(布尔值)false image_width:(null)NULL image_height :( null)NULL image_type :(字符串) image_size_str:(string)

控制器:

    public function do_upload()
{
    $config['upload_path'] = './assets/uploads/';
    $config['allowed_types']        = 'gif|jpg|png|jpeg';
    $config['max_size']             = '8192';
    $config['max_width']            = 0;
    $config['max_height']           = 0;

    $this->load->library('upload', $config);
    die(var_dump($this->upload->data('')));
    if ( ! $this->upload->do_upload('userfile'))
    {
                    $error = array('error' => $this->upload->display_errors());

                    $this->load->view('upload_form', $error);
    }
    else
    {
                    $data = array('upload_data' => $this->upload->data());

                    $this->load->view('upload_success', $data);
    }
}

查看:

<?php if (isset($error)) : echo $error; endif?>

<?php echo form_open_multipart('admin/user_authentication/do_upload');?>

<input type="file" name="userfile" size="20" />

<br /><br />

<input type="submit" value="upload" />

</form>

我已尝试修复上传路径,但返回了相同的转储。

0 个答案:

没有答案