Page 1 of 1

$_POST size problem

Posted: Thu Sep 17, 2009 3:07 am
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!

Re: $_POST size problem

Posted: Thu Sep 17, 2009 3:32 am
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.

Re: $_POST size problem

Posted: Thu Sep 17, 2009 3:39 am
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

Re: $_POST size problem

Posted: Thu Sep 17, 2009 3:49 am
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.

Re: $_POST size problem

Posted: Thu Sep 17, 2009 4:10 am
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!

Re: $_POST size problem

Posted: Fri Sep 18, 2009 12:00 am
by iamngk
it is happy to hear form you...