gpt4 book ai didi

upload - 出于安全原因,escapeshellarg() 已被禁用

转载 作者:行者123 更新时间:2023-12-03 21:40:44 27 4
gpt4 key购买 nike

当我想以任何形式上传任何内容时,我会看到 警告:出于安全原因,escapeshellarg() 已被禁用 在我的网站上留言。我能做些什么来解决这个问题?

我的框架是 codeigniter 最终版本。

这是完整的警告:

A PHP Error was encountered

Severity: Warning

Message: escapeshellarg() has been disabled for security reasons

Filename: libraries/Upload.php

最佳答案

@运算符将消除该函数可能引发的任何 PHP 错误。 你永远不应该使用它!

解决方案:

  • 删除 escapeshellarg来自 disable_functions 的字符串在 php.ini文件
  • 要求您的主机提供商删除 escapeshellarg来自 disable_functions 的字符串在 php.ini 文件中,如果您无权访问 php.ini文件
  • 自己做 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
  • 关于upload - 出于安全原因,escapeshellarg() 已被禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10384336/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com