Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
709 views
in Technique[技术] by (71.8m points)

upload - escapeshellarg() has been disabled for security reasons

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?

My framework is codeigniter final version.

Here is the full warning:

A PHP Error was encountered

Severity: Warning

Message: escapeshellarg() has been disabled for security reasons

Filename: libraries/Upload.php
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The @ operator will silence any PHP errors the function could raise. You should never use it!

Solutions:

  1. Remove the escapeshellarg string from the disable_functions in php.ini file

  2. 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

  3. 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.''';
    }
    

    and do something like this:

    // $cmd = 'file --brief --mime ' . escapeshellarg($file['tmp_name']) . ' 2>&1';
    $cmd = 'file --brief --mime ' . my_escapeshellarg($file['tmp_name']) . ' 2>&1';
    

    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.

    Helpful links: https://www.codeigniter.com/user_guide/general/core_classes.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...