How to prevent error: Use of $_FILES is discouraged in Magento 2?

How to prevent the use of global variable $_FILES in code?

Magento application does not directly use any PHP superglobals variable like $GLOBALS, $_SERVER, $_GET, $_POST, $_FILES, $_COOKIE, $_SESSION, $_REQUEST.

You don’t need to directly use $_FILES in your code for file/images save. This may be lead to security vulnerabilities. Continue reading “How to prevent error: Use of $_FILES is discouraged in Magento 2?”

Phpmd Error: The class uses sessions or cookies while not being a part of HTML Presentation layer in Magento 2.

In Magento 2, You are trying to commit the module with PHP Code standard tools GrumPHP and your module have an issue related to Sessions or cookies that are not used in the Presentation layer at that time you are facing the error like this,

The class uses sessions or cookies while not being a part of HTML Presentation layer.

You have to fixed PHPMD error by adding SuppressWarnings before the class name. Continue reading “Phpmd Error: The class uses sessions or cookies while not being a part of HTML Presentation layer in Magento 2.”