2

I can't upload images on my CMS home page, it says "Memory limit has been reached", i've been searching on internet a fix, and i found this one saying to change this code on Gd2.php ( /lib/Varien/Image/Adapter/Gd2.php ) :

    protected function _convertToByte($memoryValue)
{
    if (stripos($memoryValue, 'M') !== false) {
        return (int)$memoryValue * 1024 * 1024;
    }
    elseif (stripos($memoryValue, 'KB') !== false) {
        return (int)$memoryValue * 1024;
    }

   return (int)$memoryValue;
}

to

protected function _convertToByte($memoryValue)
{
     /*
     if (stripos($memoryValue, 'M') !== false) {
         return (int)$memoryValue * 1024 * 1024;
     }
     elseif (stripos($memoryValue, 'KB') !== false) {
         return (int)$memoryValue * 1024;
     }

     return (int)$memoryValue;
     */
     return 2147483648;
     //1024*1024*1024*2 = 2G
}

(Yes i removed the commentary codes )

but in my Gd2.php the code is different, here's the code i have:

protected function _convertToByte($memoryValue)
    {
        $memoryValue = trim($memoryValue);
        if (empty($memoryValue)) {
            return 0;
        }
        if (preg_match('~^([1-9][0-9]*)[\s]*(k|m|g)b?$~i', $memoryValue, $matches)) {
            $option = strtolower($matches[2]);
            $memoryValue = $matches[1];
            switch ($option) {
                case 'g':
                    $memoryValue *= 1024;
                    // no break
                case 'm':
                    $memoryValue *= 1024;
                    // no break
                case 'k':
                    $memoryValue *= 1024;
                    break;
                default:
                    break;
            }
        }
        $memoryValue = (int)$memoryValue;

        return $memoryValue > 0 ? $memoryValue : 0;
    }
2
  • Which Magento version you are using?
    – Macas
    Commented Feb 28, 2018 at 19:06
  • Hi @Macas, i'm using version 1.9.3.1, it's in the tag
    – Jon
    Commented Mar 1, 2018 at 16:40

1 Answer 1

1

I think you need to increase your PHP memory limit, it's not a Magento related issue, but rather a PHP/Web server one.

Try increasing the following PHP configuration values in your php.ini :

  • post_max_size
  • upload_max_filesize

https://secure.php.net/manual/en/ini.core.php#ini.post-max-size

https://secure.php.net/manual/en/ini.core.php#ini.upload-max-filesize

2
  • Hi, thanks for the reply, i would to try those configs but i can't find the php.ini in my ftp, i tried the phpinfo but it leads me to /opt/alt/php55/etc but i can't find that location in my ftp, i can only fint the php.ini.sample but i think it's not there
    – Jon
    Commented Mar 1, 2018 at 16:11
  • You most likely don't have access to that folder as that is system administrator land. I think this is not a developer job, it's a dev ops job. So I would contact the system administrator to sort it out if I were you. Also even if you could find the php.ini, I believe you have to restart the web server afterwards which you cannot do from FTP anyway so yeah, dev opts job.
    – user4864
    Commented Mar 2, 2018 at 8:45

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.