Setting post_max_size at runtime

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jamesm6162
Forum Newbie
Posts: 13
Joined: Sat Jun 28, 2008 10:31 am

Setting post_max_size at runtime

Post by jamesm6162 »

Hi

Suppose for a moment that you do NOT have access to the php.ini file....

Okay, now, I have a form to upload images and it does contain the MAX_FILE_SIZE hidden input field, and it does appear before the file upload input field.

It sets the max upload size to roughly 3MB

The current value of the php directive post_max_size is only 2M.
If I try to upload a file of about 6MB, it gives me the error:
Quote:
POST Content-Length of 7007829 bytes exceeds the limit of 2097152 bytes in Unknown on line 0

this I assumed is because of this max post value being to small (more specifically, smaller than the upload_max_filesize).

How do I change this post value at runtime to avoid this?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Setting post_max_size at runtime

Post by onion2k »

You can't change that in a script... change it in the php.ini file.

Changing it in .htaccess might work too..
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: Setting post_max_size at runtime

Post by Bill H »

Check out the ini_set() function.
upload_max_filesize is one of the items listed that can be changed in htaccess. Default is "2M"
Post Reply