4

I'm using the magento ECG coding standards on a project and am getting the following:

ERROR | Direct use of $_FILES Superglobal detected.

I've grepped through the code and can see that core uses the $_FILES superglobal, does magento have a wrapper function for this or should i ignore the error?

5

use below in place of $_FILES

try {
    $uploader = Mage::getModel('core/file_uploader', 'field_name');
    $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif'));
    $result = $uploader->save($path); 
} catch (Exception $e) {
    echo $e->getMessage();
}

To know more what possibly can be done with this approach, go to /app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.