CodeIgniter上传失败,没有错误日志,没有错误报告 [英] CodeIgniter upload fail no error logs no error reporting

查看:163
本文介绍了CodeIgniter上传失败,没有错误日志,没有错误报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用CodeIgniter上传文件.该服务器似乎发生了一些奇怪的事情,因为该代码在其他服务器上可以正常工作.我正在尝试调试问题,但未报告任何错误.

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 issue but no errors are being reported.

具体来说,代码:

if (!$this->upload->do_upload()) {
    var_dump($this->upload->display_errors());
    exit();
}

我已打开error_reporting(E_ALL)和display_errors,但未显示任何内容.只是一个空白页.我知道这些设置有效,因为如果出现语法错误,则会显示错误.当我上传文件时,这只是一个完整的空白页. 100%确定要上传文件.

I have turned error_reporting(E_ALL) on and display_errors, nothing is shown. Just a blank page. I know these settings work because if I make a syntax error, the errors will show. It's just a complete blank page when I upload a file. It is 100% sure uploading a file.

我什至打开了CodeIgniter日志,错误报告级别设置为4,但是根本没有写入日志文件.我已将其设置为默认日志文件.

I have even turned on the CodeIgniter log, error reporting level set to 4, but no log files are being written at all. I have set it to the default log file.

最后,我检查了file_uploads的PHPinfo()设置,一切似乎都还不错.它们设置为开,没有疯狂的上传限制或类似的限制.

Finally, I checked the PHPinfo() settings for file_uploads and all seems okay. They are set to on, no crazy upload limit or anything like that.

我可以使用fopen()创建文件,然后将文件写入服务器.

I can create files with fopen() and it writes the file to the server fine.

关于我可以做些什么来尝试和调试的任何想法?我没有服务器访问权限(用于客户端),所以我试图依靠使用SFTP和错误输出.但是我什么也没得到.

Any ideas on what I can do to try and debug? I don't have server access (it's for a client) so I'm trying to rely on using SFTP and error output. But I'm getting nothing.

我设法获取了日志文件来输出此消息:

I managed to get the log file to output this:

INFO - 2016-11-28 01:24:07 --> Session: Class initialized using 'files' driver.
INFO - 2016-11-28 01:24:07 --> Model Class Initialized
INFO - 2016-11-28 01:24:07 --> Controller Class Initialized
INFO - 2016-11-28 01:24:07 --> Model Class Initialized
INFO - 2016-11-28 01:24:07 --> Model Class Initialized
INFO - 2016-11-28 01:24:07 --> Helper loaded: email_helper
INFO - 2016-11-28 01:24:07 --> Upload Class Initialized

因此,脚本似乎在上载类初始化"部分停止了.

So it seems the script stops at the Upload Class Initialized part.

推荐答案

给出

它的CodeIgniter 3.1.2(最新),并且正在运行PHP 5.4.在我假定的ini设置中,主机启用了error_reporting和display_errors.他们的主人是Dreamhost.

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.

我可以肯定地说99%您没有启用 Fileinfo扩展名,并且因此受到CodeIgniter中的错误"#4887的影响

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

Fileinfo扩展名描述为从PHP 5.3起默认启用. php.net 上的"0",这就是为什么在3.1.1版中从CI_Upload中删除了function_exists('finfo_file')检查的原因.但是事实证明,某些发行版和/或托管服务提供商明确禁用了该扩展,显然您受此影响,从而导致以下错误:

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致命错误:在第1225行的/path/to/system/libraries/Upload.php中调用未定义的函数finfo_file()

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

您没有看到该错误,因为您实际上并未为CodeIgniter应用程序启用display_errors,并且可能没有在日志中查找该错误...
默认情况下,框架本身将始终 启用error_reporting,并且如果在 index.php ENVIRONMENT设置为测试"或生产",则禁用display_errors. >文件-我猜您已将其设置为生产".因此,在php.ini中启用这两个设置都没有关系,因为CodeIgniter会覆盖它们.

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.

此问题影响CodeIgniter版本3.1.1和3.1.2.要在3.1.3发行之前解决它,您可以启用Fileinfo扩展名或应用此修补程序:

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

这篇关于CodeIgniter上传失败,没有错误日志,没有错误报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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