当我想以任何形式上传任何内容时,我会看到警告:出于安全原因,escapeshellarg() 已被禁用在我的网站上留言。我可以做什么来解决这个问题?
我的框架是 codeigniter 最终版本。
这是完整的警告:
A PHP Error was encountered
Severity: Warning
Message: escapeshellarg() has been disabled for security reasons
Filename: libraries/Upload.php
The @
运算符将消除该函数可能引发的任何 PHP 错误。你永远不应该使用它!
解决方案:
去除escapeshellarg
字符串从disable_functions
in php.ini
file
要求您的主机提供商删除删除escapeshellarg
字符串从disable_functions
如果您无权访问 php.ini 文件php.ini
file
-
自己做escapeshellarg
。该函数仅转义给定字符串中的任何单引号,然后在其周围添加单引号。
function my_escapeshellarg($input)
{
$input = str_replace('\'', '\\\'', $input);
return '\''.$input.'\'';
}
并做这样的事情:
// $cmd = 'file --brief --mime ' . escapeshellarg($file['tmp_name']) . ' 2>&1';
$cmd = 'file --brief --mime ' . my_escapeshellarg($file['tmp_name']) . ' 2>&1';
但最好的办法是延长Upload.php
库并覆盖_file_mime_type
函数而不是在 CodeIgniter 的核心上进行更改,这样如果您想要更新 CodeIgniter,您就不会丢失它。
有用的网址:https://www.codeigniter.com/user_guide/general/core_classes.html https://www.codeigniter.com/user_guide/general/core_classes.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)