$_POST size problem

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
Xaeon
Forum Newbie
Posts: 3
Joined: Thu Sep 17, 2009 3:01 am

$_POST size problem

Post by Xaeon »

Hi, I have recently become flumoxed by a little problem and am wondering if anyone could help with some ideas.

I am writing a simple PHP upload file script which also takes some user data to be later stored in a database, which usually is no problem, however in my PHP.ini the $_POST size limit has been set to about 8MB, and when I attempt to upload a file greater than this value (using <input type="file"> ) the post data is completely lost on the next page, including all the user data.

The problem I have here is error handling when a user supplies a file that is too large for this array, since I have no PHP error, or post data to catch.

Any ideas?

Cheers!
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: $_POST size problem

Post by jackpf »

Umm...shouldn't the file be put into the $_FILES array rather than $_POST?

Also, you could check if $_SERVER['REQUEST_METHOD'] is 'POST' and $_POST is empty, then there has been an error.
iamngk
Forum Commoner
Posts: 50
Joined: Mon Jun 29, 2009 2:20 am

Re: $_POST size problem

Post by iamngk »

you have to change following configration in your configration file or you can also use .htaccess to modfiy that.

post_max_size
upload_max_filesize
max_input_time

Also, post_max_size should be greater then upload_max_filesize
Xaeon
Forum Newbie
Posts: 3
Joined: Thu Sep 17, 2009 3:01 am

Re: $_POST size problem

Post by Xaeon »

Hi,

thanks guys, I think iamngk may have pointed out the problem.

Max post size is set to 8MB
Max upload is 10MB.

That could be why everything is dissapearing on me, I will try swapping them around when there is a sysadmin about (unfortunately at my workplace even simple things need to go through them).

I will let you know what happens,

Many Thanks.
Xaeon
Forum Newbie
Posts: 3
Joined: Thu Sep 17, 2009 3:01 am

Re: $_POST size problem

Post by Xaeon »

Gave up waiting and changes the values using a .htaccess

The script now works, and I can now debug large filesize problems using

Code: Select all

 
$_FILES['name']['error']
 
So a note to summarize my problem:

if

post_max_size

is less than

upload_max_size

within php.ini or htaccess (check with phpinfo())

$_POST and $_FILES arrays are lost.

Many thanks for your help guys!
iamngk
Forum Commoner
Posts: 50
Joined: Mon Jun 29, 2009 2:20 am

Re: $_POST size problem

Post by iamngk »

it is happy to hear form you...
Post Reply