upload_max_filesize headache

Hi there,

I need to allow a user to upload files of between 5-10MB. I’m testing the feature out locally using apache, and I get the $_FILES[‘upload’][‘error’] of 1, meaning the file exceeds the maximum upload size stipulated in the php.ini file.

So I found the php.ini file and changes upload_max_filesize = 2M, to upload_max_filesize = 10M, but I’m still getting the same error message.

Actually, as I type this I realise that I should probably restart apache. But I don’t know how to do that! Looking on-line gives me a lot of command line stuff that’s over my head.

Could anyone help me out with a simple step-by-step guide to restarting apache without breaking anything :confused:

Many thanks,
Mike

Yes, you do need to restart Apache for the changes to take effect.

Are you running Apache on linux (if so, what distro?) or on windows (via WAMP / XAMPP / etc) ?

Hi there,

Thanks for your reply. I’m running apache on mac os x, and I did manage to restart using


sudo apachectl restart

entered my password, and after a little wait, the command prompt reappeared. However, I’m still getting the same error code for my upload, upload exceeds upload filesize limit.

Is there anything else I should check. I have a php.ini file, and a php.ini.default fine in my private/etc folder. Do I need to change the .default file as well?

Many thanks,
Mike

No you only need to change the .ini

Also take a look at post_max_size

if post_max_size is smaller than upload_max_filesize then post_max_size is the upper limit:

upload_limit = min(upload_max_filesize, post_max_size)

Also, set them a bit higher than 10M to allow for HTTP overhead; something like 12M should do.

Thanks for your reply,

I have changed both post_max_filesize and upload_max_filesize.

When I checked using phpinfo(), i see that the changes have not taken effect, even after restarting apache.

I am running Apache 5.2.5 on a Mac OS X 10.5.8.

I have been working through Kenvin Yank’s SitePoint publication, “Build Your Own Database Driven Website Using PHP and MySQL”, and have made changes to the php.ini file located at private/etc/php.ini which have taken effect. (Magic Quotes etc.)

Phpinfo() is checking /usr/local/php5/lib for the configuration file. Looking in that directory all I have is ‘php.ini-recommended’, which I can’t believe is being used by apache.

My only thoughts could be that some extension or another is over-riding the upload_max_filesize command.

Am I on the right track? If so where would this likely be?

Many thanks,
Mike

I’m not sure if there are extensions that can override it, but if there are your best bet would be the Suhosin PHP hardening patch.

Thanks for your reply ScallioXTX, which went straight over my head! :confused:

I have fixed the problem though. I placed a copy of my php.ini file into the directory that phpinfo told me apache was checking for a ini file. Turns out that none was loaded.

The thing that confused me was Kevin Yank’s instruction to change private/etc/php.ini, which actually make no difference to apache. Perhaps he was referring to an older version of apache. shrug

Once again, thanks for your help. :slight_smile: