我在许多行中的文件核心/安全性中获得了大量的错误代码。
这只是因为这两行代码而发生的:
$fileFinal = file_get_contents($fileTmp);
$projectFile['file'] = $fileFinal;
虽然我知道这不是将文件插入数据库的最佳做法,但这不是问题所在。
这是我的全部代码:
$fileName = $file['name'];
$fileTmp = $file['tmp_name'];
$fileSize = $file['size'];
$fileType = $file['type'];
$fileFinal = file_get_contents($fileTmp);
if($fileFinal != null){
$projectFile = array();
$projectFile['file'] = $fileFinal;
$projectFile['file_name'] = $fileName;
$projectFile['file_type'] = $fileType;
$projectFile['file_size'] = $fileSize;
$projectFile['date'] = date('Y-m-d H:i:s');
$this->projectsModel->addFile($projectFile);
}
这有效,但有很多错误。这些文件实际上是插入到数据库中的,但在我的控制台中我有几十行错误:
遇到PHP错误
严重性:8192
消息:preg_replace():/ e修饰符是 不推荐使用,请改用preg_replace_callback
文件名: core / Security.php
行号:512
遇到PHP错误
严重性:8192
消息:preg_replace():/ e修饰符是 不推荐使用,请改用preg_replace_callback
文件名: core / Security.php
行号:513
遇到PHP错误
严重性:8192
消息:preg_replace():/ e修饰符是 不推荐使用,请改用preg_replace_callback
文件名: core / Security.php
行号:512
遇到PHP错误
严重性:8192
消息:preg_replace():/ e修饰符是 不推荐使用,请改用preg_replace_callback
文件名: core / Security.php
行号:513
我可以在这里提出更多错误。所以我开始逐行调试,直到我到达:
$projectFile['file'] = $fileFinal;
将此行更改为:
$projectFile['file'] = null;
完美运作,我没有收到任何错误。
接收字段“file”的数据库中的列是mediumblob
类型。
我必须重申:即使出现控制台错误,我的文件也很好地插入数据库中,但是,我的问题是插入文件后我发送了json_message
到$.post
,它充满了错误,我无法正确解析它。
答案 0 :(得分:0)
所以它似乎是一个bug,至少对我而言。我总是在我的更新中使用xss_clean()
函数插入函数。
$this->security->xss_clean($data);
问题的原因是什么。通过删除它,所有错误都消失了,这意味着file_get_contents()
值不受欢迎。