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

查看:35
本文介绍了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.

推荐答案

Given 这条评论:

它的 CodeIgniter 3.1.2(最新)并且他们正在运行 PHP 5.4.Error_reporting 和 display_errors 由主机启用,在我假设的 ini 设置中.他们的主人是 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% 肯定地说您没有启用 文件信息扩展,并且因此受到 CodeIgniter 中 "bug" #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 起默认启用.0" on php.net,这就是为什么在 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,如果您将 ENVIRONMENT 设置为testing",则禁用 display_errorsindex.php 文件中的生产" - 我猜你已经将它设置为生产".因此,在 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 扩展或应用此补丁:https://github.com/bcit-ci/CodeIgniter/commit/7cc08237c2a15daf283e2bc61501bdc086740311

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天全站免登陆