I'm just testing Magento 1.9.2 with Php 7. All seemed to work, but suddenly I tried to upload image for the product. I got error like below:

Fatal error</b>:  Uncaught Error: Function name must be a string in /home/admin/domains/store.com/public_html/dev/lib/Varien/File/Uploader.php:259
Stack trace:
#0 /home/admin/domains/store.com/public_html/dev/lib/Varien/File/Uploader.php(180): Varien_File_Uploader-&gt;_validateFile()
#1 /home/admin/domains/store.com/public_html/dev/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php(46): Varien_File_Uploader-&gt;save('/home/admin/dom...')
#2 /home/admin/domains/store.com/public_html/dev/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Catalog_Product_GalleryController-&gt;uploadAction()
#3 /home/admin/domains/store.com/public_html/dev/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action-&gt;dispatch('upload')
#4 /home/admin/domains/store.com/public_html/dev/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard-&gt;match(Object(Mage_Core_Controller in <b>/home/admin/domains/store.com/public_html/dev/lib/Varien/File/Uploader.php

Anybody know how to fix it?

Function affected in upload.php at line around 259

protected function _validateFile()
        if ($this->_fileExists === false) {

        //is file extension allowed
        if (!$this->checkAllowedExtension($this->getFileExtension())) {
            throw new Exception('Disallowed file type.');
        //run validate callbacks
        foreach ($this->_validateCallbacks as $params) {
            if (is_object($params['object']) && method_exists($params['object'], $params['method'])) {

2 Answers 2


http://php.net/manual/de/migration70.incompatible.php https://wiki.php.net/rfc/uniform_variable_syntax

Due to uniform variable syntax the code is now interpreted strictly from left to right.

The line


should be


You can find a overview of all files to edit in this answer.

  • Cool, works 100% I hope Magento 1.9.2 doesn't have any other php 7 incompatibility. Thanks for help!
    – sellio
    Commented Dec 9, 2015 at 23:09
  • this code work for me magento
    – matinict
    Commented Aug 29, 2016 at 6:25
  • This solution has all the files you'll need to edit for a good PHP7 performance: magento.stackexchange.com/a/105604/37536
    – Asitis
    Commented Aug 30, 2016 at 11:42
  • Awesome...It's working fine for me Commented Dec 27, 2016 at 20:05

In Addition to the answers above, don't forget to check the file:

\includes\src\Varien_File_Uploader.php on line 259




  • simply re-compile rather than edit these temp files?
    – Andy
    Commented Dec 20, 2017 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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