WordPress fatal error message may sometimes occur when you try to upload an image in WordPress. This shows you how to solve this error

Why does the WordPress fatal error message occur?

  1. You are trying to upload a medium sized image in WordPress
  2. You receive an alert that says, “Fatal error: Allowed memory size of 33554432 bytes exhausted” when try to upload an image with medium file size.

 How you can solve it

The first advised solution for a WordPress Fatal Error Message when trying to upload an image with WordPress is to try to increase the amount of memory that is allocated to PHP. The amount you will be able to increase it to depends on the limit set by your host. It will either be 32MB, 64MB, 128MB or 256MB.

Step 1

If you can edit your PHP.inifile, update your memory_limit in PHP.ini as follows:memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)

  • memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)
  • Try to change 64M to 128M

memory_limit = 64M - Fixing WordPress fatal error message

Step 2

Try to re-upload the same image. If it works, you are done!

Step 3

If it doesn’t work, you need to edit your .htaccess file

Step 4

Add the following script to your .htaccess file:
-php_value memory_limit 128M

Change limit to 128M - Fixing WordPress fatal error message

Step 5

Try to re-upload the same image. If it works, you are done!

Step 6

If it still doesn’t work, you need to edit your wp-config.php file
wp-config - Fixing WordPress fatal error message

Step 7

Add the following script to your wp-config.php file:

 Increasing memory allocated to PHP define(‘WP_MEMORY_LIMIT’, ‘128M’);

WP_MEMORY_LIMIT_128 - Fixing WordPress fatal error message

Step 8

Try to re-upload the same image. If it works, you are done!

Step 9

If it still doesn’t work, the fourth and final fix is to create a PHP.ini file in your wp-admin folder. Do this as follows:
        1. Open up your Notepad
        2. Insert the following code into Notepad exactly as it appears:
          memory_limit = 64M ;

memory_limit = 64M-php - Fixing WordPress fatal error message

3. Save as “PHP.ini”


php.ini

4. Upload this file to “wp-admin” directory

wp-admin

5. Try to re-upload the image.

Most likely, you would no longer see the WordPress fatal error message. You’re done!