codeigniter 3,文件上传给出 HTTP ERROR 500

codeigniter 3, file upload gives HTTP ERROR 500

我是 CodeIgniter 3 框架的新手,所以我对这个错误有点了解。基本上,当我尝试上传图像时,它会抛出 HTTP ERROR 500 并且服务器上的错误日志中没有错误。

控制器的功能如下:

if ($_POST)
{
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'gif|jpg|jpeg|png';
    $config['max_size'] = '1024';
    $config['max_width'] = '1920';
    $config['max_height'] = '1280';
    $this->load->library('upload', $config);

    foreach ($_FILES as $fieldname => $fileObject)
    {
        if (!empty($fileObject['name']))
        {
            $this->upload->initialize($config);
            if (!$this->upload->do_upload($fieldname))
            {
                var_dump($this->upload->display_errors());
            }
            else
            {
                 // SUCCESS
            }
        }
    }
}

我已经用 is_dir、is_writable 等检查了 $config['upload_path']。 chmod 为 777。$fieldname/$fileObject 具有正确的值。没有添加 .htaccess,我在子域 root

中工作

任何建议将不胜感激,因为我没有想法:)

@STL 你使用 XAMPP 和 Codeigniter 3.1.2 吗?我也经历过。 我认为这是 CodeIgniter 3.1.2 中的错误,因为 fileinfo.dll 在 XAMPP 或 CentOS 中默认未加载。也许您应该检查服务器中的文件信息扩展名并加载它,或者只是将 Codeigniter 系统降级到 3.1.0。

来源:Github

在php.ini

中启用扩展=php_fileinfo.dll

this may be php.ini file problem

打开您的 php.ini 文件

搜索扩展名=php_fileinfo.dll

如果您使用的是xampp,它可能会被默认注释

改变

;extension=php_fileinfo.dll

to

extension=php_fileinfo.dll

并重新启动您的 xampp...

这解决了我的问题