我得到了大量的错误代码在文件核心/安全在许多行。
之所以会发生这种情况,是因为这两行代码:
$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);
}
这是可行的,但有大量的错误。这些文件实际上是插入到数据库中的,但在我的控制台中,我有几十行错误:
A PHP Error was encountered 严重程度: 8192消息: preg_replace():不推荐使用/e修饰符,而是使用preg_replace_callback 文件名: core/Security.php 行号:512 A PHP Error was encountered 严重性: 8192 消息: preg_replace():不推荐使用/e修饰符,而是使用preg_replace_callback 文件名: core/Security.php 行号:513 A PHP Error was encountered 严重性: 8192 消息: preg_replace():不推荐使用/e修饰符,而是使用preg_replace_callback 文件名: core/Security.php 行号:512 A PHP Error was encountered 严重性: 8192 消息: preg_replace():不推荐使用/e修饰符,而是使用preg_replace_callback 文件名: core/Security.php 线路号码: 513
我可以在这里放更多的错误。因此,我开始逐行调试,直到我到达:
$projectFile['file'] = $fileFinal;
将此行更改为:
$projectFile['file'] = null;
工作完美,我没有收到任何错误。
接收字段"file“的数据库中的列是mediumblob
类型。
我必须重复一遍:即使有控制台错误,我的文件也被很好地插入到数据库中,但是,我的问题是在插入文件之后,我向$.post
发送了一个$.post
,而且由于它充满了错误,所以我无法正确地解析它。
发布于 2014-07-18 08:37:35
至少对我来说是个小虫子。我总是在我的更新和插入函数中使用xss_clean()
函数。
$this->security->xss_clean($data);
这就是问题的原因。通过删除它,所有错误都消失了,这意味着file_get_contents()
值不受此函数的欢迎。
https://stackoverflow.com/questions/24829765
复制相似问题