Codeigniter上传错误请帮助我

fquxozlt  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(107)

帮助我请Codeigniter上传文件。我的错误:
遇到PHP错误
严重性:警告
消息:getimagesize():open_basedir限制生效。文件(/var/tmp/phpHyN 6 Ny)不在允许的路径内:(/var/www. vhosts/jizzax. uz/:/tmp/)
文件名:文件名
行号:609
遇到PHP错误

Severity: Warning

Message: getimagesize(/var/tmp/phpHyN6Ny): failed to open stream: Operation not permitted

Filename: libraries/Upload.php

Line Number: 609
Array ( [error] =>

The filetype you are attempting to upload is not allowed.
)
r8uurelv

r8uurelv1#

CodeIgniter的文档明确指出,您需要定义文件上传所允许的文件类型。如果您不这样做,则没有默认的允许类型列表。
文档中的相关代码可以在下面找到。特别是$config数组的'allowed_types'元素。

function do_upload()
{
    $config['upload_path'] = './uploads/';
    $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('upload_form', $error);
    }
    else
    {
        $data = array('upload_data' => $this->upload->data());

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

相关问题