I'm putting this in primarily because there are many bug reports filed about having problems with upload and file field not being able to upload larger files. I've been battling this for a little while, and it took me a long time to find what the issue is and to fix it, so I thought I'd put in an issue about the solution.

I'm using mod_fcgid to run PHP on my servers, and I recently had a lot of trouble with upload module where some files would not upload succesfully, and some would The failures were fairly silent, didn't log any errors, and the end result would always either be a report that the file could not be uploaded (and no error message in the logs) or the file WOULD upload, but would be corrupted.

Turns out that some of the recent versions of mod_fcgid have a bug that breaks file uploads. Versions after 2.3.2 and before 2.3.5 will only reliably upload files that are smaller than FcgidMaxRequestInMem is configured. This is a bug, and it was fixed in 2.3.5. A possible workaround is to put in a value for FcgidMaxRequestInMem that is larger than your maximum uploads, but rebuilding mod_fcgid out of the current svn source made the problem go away altogether. If you're running mod_fcgid and are having upload problems, you should check what version of mod_fcgid you're using.

Comments

Carlos Miranda Levy’s picture

I have posted detailed instructions for downgrading to libapache2-mod-fcgid to 1:2.2-1 on my blog at http://www.socinfo.com/ubuntu/php/fcgid/bug-fix-corrupt-files-upload

Short Summary here:

  • First, download a trusted version of libapache2-mod-fcgid to 1:2.2-1 from http://packages.ubuntu.com/karmic/libapache2-mod-fcgid . In my case, running Ubuntu 64bit being in Singapore now, the closest mirror was Korea, so I did:
    wget http://kr.archive.ubuntu.com/ubuntu/pool/universe/liba/libapache2-mod-fcgid/libapache2-mod-fcgid_2.2-1_amd64.deb
    
  • Then install it with:
    sudo dpkg -i libapache2-mod-fcgid_2.2-1_amd64.deb
    
  • Finally, you need to "hold" this version so that it is not upgraded later on any maintenance process or update you do:
    sudo -s
    echo libapache2-mod-fcgid hold | dpkg --set-selections

That's it. You can reload Apache and restart Apache:

sudo /etc/init.d/apache2 reload
sudo apache2ctl graceful

You can see the actual version of libapache2-mod-fcgid installed by typing:

sudo dpkg -s libapache2-mod-fcgid

And you can do an actual upgrade to test that this version is kept throughout updates. You will see a notice when doing the upgrade that this package will be ignored.

sudo apt-get update
sudo apt-get upgrade

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
  libapache2-mod-fcgid
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

sudo dpkg -s libapache2-mod-fcgid

Finally, don't forget to keep an eye on the Ubuntu 10.04 package repositories, for eventually they will upgrade to include a newer version of libapache2-mod-fcgid which does not present this problem. Version 2.3.5 reportedly fixes the issue (see here). At that moment you can "unhold" the package for it to be included in upgrade operations.

Detailed info and additional links at:
http://www.socinfo.com/ubuntu/php/fcgid/bug-fix-corrupt-files-upload

kars-t’s picture

Status: Active » Fixed

Thanks for the information. ThisThanks for the information.
Maybe this could be added to documentation somewhere or you should provide a blogpost about it. But this issue seems fixed than.

Status: Fixed » Closed (fixed)
Issue tags: -mod_fcgid, -upload failure

Automatically closed -- issue fixed for 2 weeks with no activity.