Error “file is empty” when uploading images in WordPress

I’m running a WordPress 2.9.2 Blog with a custom install of Debian in a Amazon Web Services EC2 machine.

Everything was working fine until monday. Then came tuesday, and suddendly, overnight, I can’t upload pictures using the default WP file uploader (either flash or html).

Read More

When I try to upload a picture, it displays the following error:

File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini

So I checked out my php.ini, and modified some settings as follows:

  • upload_max_filesize: 64M
  • post_max_size: 90M
  • memory_limit: 128M
  • max_excecution_time: 600
  • max_input_time: 600

But it didn’t work. Then I tried chmod -ing the wp-content/uploads/ folder and its subfolders to 777. Didn’t work.

Did some research on Google, and added following lines to .htaccess:

<IfModule mod_security.c>
SetEnvIfNoCase Content-Type
"^multipart/form-data;" "MODSEC_NOPOSTBUFFERING=Do not buffer file uploads"
</IfModule>

<IfModule mod_gzip.c>
mod_gzip_on No
</IfModule>

Didn’t work. Finally, increased WPs memory limit in wp-settings.php file. Didn’t work.

So I’m all out of options by now. Anyone has any ideas on how to solve this? It’s really bugging me and my client off!

Thanks in advance!

Related posts

Leave a Reply

3 comments

  1. Not sure if this was the case (it has been over a year), but in many cases, for this same issue, the problem was due the hard drive being full.

    Stupid, I know.

    Just check how much space is left, and, if none, go delete logs. Apache, PHP, MySQL. They add up a lot of data when enough time is given.

  2. First I created a file called phpinfo.php and put this in it:

    <?php
       phpinfo();
    ?>
    

    I accessed the page (I’m using wamp) at localhost/phpinfo.php and checked

    upload_max_filesize: 
    post_max_size: 
    memory_limit: 
    

    I found the location of php.ini and changed these variables upwards to

    upload_max_filesize = 100M
    post_max_size = 100M
    memory_limit = 128M
    

    Then I restarted apache and checked that phpinfo.php reflected the new settings. I was still getting the error, so I changed the directory for the site and all sub directories from read-only to read-write. That seemed to do the trick.

  3. I had a similar problem. I receive the “empty file” message and proceed to reload the same file that just report the warning. A lot of messages saying ” media xxxx already exists” appears and after check, all the posts have been imported with all the attachments. So basically I had to upload each import file twice but on second time it was faster. Hope it helps.