I'm developing a class to support multiple uploads using the Codeigniter framework and I've decided to parse my code using some online tools.
One of these was code climate ; I noticed that when checking the reports for code improvement it says that it is not recommended to use superglobals such as $_FILES
even in functions specific to the validation, for example;
public function hasFile($key)
{
if (!isset($_FILES[$key]) {
throw new Exception("Não existe o indice $key", 1);
}
return TRUE;
}
I tried to change this by creating an attribute called key
public $key = 'userFile';
And call it within functions
if (!isset($_FILES[$this->key]) {.....
But I keep getting the report that this is not a good practice! I also looked in the PHP documentation if there is any superglobal filter type $_FILES
using the function filter_input
and also not found.
What would be the best way to validate the superglobal $_FILES
?
print the report;
In the function in question I do not assign the super-global to any variables, I just perform the validation as in the example above.