codeigniter 3,文件上传显示HTTP错误500 [英] codeigniter 3, file upload gives HTTP ERROR 500

查看:55
本文介绍了codeigniter 3,文件上传显示HTTP错误500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm new to the CodeIgniter 3 framework so i'm a bit in the deep with this bugs. Basically, when i try to upload an image it throws me the HTTP ERROR 500 and no errors in the error log on the server.

这是控制器的功能:

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文件,我正在子域的根目录中工作

i've checked the $config['upload_path'] with is_dir, is_writable and such. It's chmod to 777. The $fieldname/$fileObject have correct values. There is no .htaccess added and i'm working in the subdomain root

由于我没有主意,因此我们将不胜感激任何建议:)

Any suggestions would be greatly appreciated as i'm out of ideas :)

推荐答案

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

@STL do you Use XAMPP and Codeigniter 3.1.2 ? i experience this too. i think it's a bug in CodeIgniter 3.1.2 as fileinfo.dll is not loaded by default in XAMPP or in CentOS. maybe you should check the fileinfo extension in your server and load it or just downgrade the Codeigniter system to 3.1.0.

source: Github

这篇关于codeigniter 3,文件上传显示HTTP错误500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆