Codeigniter: File upload issue in 3.1.1 & 3.1.2

Created on 28 Oct 2016  路  13Comments  路  Source: bcit-ci/CodeIgniter

After upgrading to 3.1.1, file upload not working.
HTTP ERROR 500 occurs.
PHP version : 5.6.15

The same code works with CI version 3.1.0 or lower.
I have tried with latest CI release 3.1.2, still it is not working.

Regression

Most helpful comment

Since most people are using these development and production environments the issues were reported.

Captain Obvious, is that you? :)

All 13 comments

The HTTP 500 status code means "server-side error", practically translating to "something doesn't work", which you're saying anyway.

But there's a ton of stuff going on in there ... please provide more info.

I am using this simple code to upload files

public function do_upload()
        {
                $config['upload_path']          = './uploads/';
                $config['allowed_types']        = 'csv';               

                $this->load->library('upload', $config);

                if ( ! $this->upload->do_upload('csvfile'))
                {
                        echo $this->upload->display_errors();

                }
                else
                {
                        $data = array('upload_data' => $this->upload->data());

                        echo 'Upload Success';
                }
        }

When trying to upload the file HTTP Error 500 appears.
There is no other specific error shown or logged.
Log ends at INFO - 2016-10-28 22:03:06 --> Upload Class Initialized

The same function works perfectly with CI system 3.1.0 or lower version.
My php version 5.6

The same issue reported by other users.
http://forum.codeigniter.com/thread-66504-post-337924.html

Unfortunately, that's not saying anything more ...

Yes, what other information do you expect?

Something that actually points to the supposedly erroneous part of the code ...

I don't know what your logging error level is, or if/where your PHP errors are logged - that may help.
Try commenting out some pieces of code in CI_Upload to see when the error disappears ... stuff like that, you know how to debug.

codeigniter error - copy
this is the issue, he wrote about, but i think he made the env. to production not development.

, you need enable in php.ini ;extension=fileinfo.so or ;extension=php_fileinfo.dll

Thanks.
Enabling the php_fileinfo extension works.
I don't know why errors not displayed in development environment. Also, I set ini_set('display_errors', 1); at top of index.php file.
For local XAMPP, editing the php.ini file is enough just uncomment the following line
extension=php_fileinfo.dll
For WHM/Cpanel Apache rebuild needs to install the fileinfo extension.

@karthik-code @hstreams Did you use XAMPP when you encountered the issue?

I encountered the issue both in local development environment XAMPP (Windows) and in production environment LAMP (CentOS).
I wish the required php extensions should be mentioned in the CI upgrade notes.

php.net itself says that this extension is enabled by default since PHP 5.3.

Thus, having to manually enable it is the same as having to manually enable e.g. sessions - it's absurd, and you should blame XAMPP, and apparently CentOS too.

This was not supposed to be a "new requirement", I don't understand why everybody treats it like such.
Especially since we usually get immediate complaints about even the most obscure issues, and we even managed to make _a whole new release_ before this even got reported.

Fileinfo module is disabled by default in Cpanel installations.
https://documentation.cpanel.net/display/EA/PHP+Module%3A+Fileinfo

Also, the same is disabled by default in XAMPP installations.
Since most people are using these development and production environments the issues were reported.

Since most people are using these development and production environments the issues were reported.

Captain Obvious, is that you? :)

Was this page helpful?
0 / 5 - 0 ratings