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;
    }
  • Which Magento version you are using? – Macas Feb 28 '18 at 19:06
  • Hi @Macas, i'm using version 1.9.3.1, it's in the tag – Jon Mar 1 '18 at 16:40
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

  • 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 Mar 1 '18 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. – デリエゴくん Mar 2 '18 at 8:45

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.