Codeigniter上传错误帮助我解决


Codeigniter upload error help me plase

帮助我放置Codeigniter上传文件。我的错误:

遇到PHP错误

严重性:警告

消息:getimagesize():open_basedir限制生效。文件(/var/tmp/phpHyN6Ny)不在允许的路径内:(/var/www/vhosts/jizzax.uz/:/tmp/)

文件名:librarys/Upload.php

行号: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.
) 

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