本文介绍了由于安全原因,escapeshellarg()已被禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 当我想以任何形式上载任何内容时,在我的网站上看到警告:escapeshellarg()已出于安全原因而被禁用消息。我该怎么办才能解决此问题?When I want to upload anything in any form I see the Warning: escapeshellarg() has been disabled for security reasons message on my site. What can I do to fix this?我的框架是codeigniter最终版本。My framework is codeigniter final version.以下是完整的警告:A PHP Error was encounteredSeverity: WarningMessage: escapeshellarg() has been disabled for security reasonsFilename: libraries/Upload.php推荐答案 @ 运算符将使该函数可能引起的任何PHP错误均保持沉默。 永远不要使用它!The @ operator will silence any PHP errors the function could raise. You should never use it!解决方案: 从 php.ini中的 disable_functions 中删除 escapeshellarg 字符串文件Remove the escapeshellarg string from the disable_functions in php.ini file询问您的主机提供商以将其删除 escapeshellarg 字符串从 disable_functions (如果您无权访问 php.ini 文件Ask your host provider to remove Remove the escapeshellarg string from the disable_functions in php.ini file if you don't have an access to the php.ini file制作自己的 escapeshellarg 。该函数只对给定字符串中的所有单引号进行转义,然后在其周围添加单引号。make your own escapeshellarg. The function only escapes any single quotes in the given string and then adds single quotes around it.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,就不会丢失它。But what is best is to extend the Upload.php library and override the _file_mime_type function instead of changing on the core of CodeIgniter so that you will not lose it if you ever want to update CodeIgniter.有用的链接: https://www.codeigniter .com / user_guide / general / core_classes.html 这篇关于由于安全原因,escapeshellarg()已被禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-17 00:06