I used $_FILES
when uploading files, but magento-connect
do not allow to use global variables, and it generates an error in the validation report:
Direct use of $_FILES Superglobal detected
How can I fix this error?
I used $_FILES
when uploading files, but magento-connect
do not allow to use global variables, and it generates an error in the validation report:
Direct use of $_FILES Superglobal detected
How can I fix this error?
We had the same issue but a little search in the core and also this link helped us figure out the solution
you've to use
$uploader = $this->_objectManager->create(
'Magento\MediaStorage\Model\File\Uploader',
['fileId' => 'my_file_uploader']
);
in place of $_FILES and it's much better like this, you can access various methods in the object. To check the output, use:
var_dump($uploader->validateFile());
this will return an array with details about the file uploaded.
Hope it helps.