-1

帮我把Codeigniter上传文件。我的错误:

遇到 PHP 错误

严重性:警告

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

文件名:库/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.
) 
4

1 回答 1

0

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);
    }
}
于 2014-09-18T07:40:05.763 回答