CodeIgniter upload fail no error logs no error reporting

后端 未结 1 1851
夕颜
夕颜 2020-12-12 06:55

I am trying to upload a file using CodeIgniter. This server seems to have something strange going on because the code works fine on other servers. I\'m trying to debug the i

相关标签:
1条回答
  • 2020-12-12 07:18

    Given this comment:

    Its CodeIgniter 3.1.2 (latest) and they are running PHP 5.4. Error_reporting and display_errors was enabled by the host, in the ini settings I assume. Their host is Dreamhost.

    I can say with 99% certainty that you don't have the Fileinfo extension enabled, and are thus affected by "bug" #4887 in CodeIgniter.

    The Fileinfo extension is described as "enabled by default as of PHP 5.3.0" on php.net, which is why a function_exists('finfo_file') check was removed from CI_Upload in version 3.1.1. But it turned out some distributions and/or hosting providers explicitly disable the extension, and apparently you are affected by that, resulting in the following error:

    PHP Fatal error: Call to undefined function finfo_file() in /path/to/system/libraries/Upload.php on line 1225

    You don't see the error because you didn't actually enable display_errors for the CodeIgniter application, and probably didn't look in the logs for it ...
    The framework itself will always enable error_reporting by default, and disable display_errors if you set your ENVIRONMENT to 'testing' or 'production' in its index.php file - I'm guessing you have it set to 'production'. Hence, it doesn't matter that either of these settings are enabled in php.ini, because CodeIgniter will override them.

    The issue affects CodeIgniter version 3.1.1 and 3.1.2. To resolve it before 3.1.3 comes out, you can either enable the Fileinfo extension or apply this patch: https://github.com/bcit-ci/CodeIgniter/commit/7cc08237c2a15daf283e2bc61501bdc086740311

    0 讨论(0)
提交回复
热议问题