Fixing an Empty $_POST Array in PHP

Even experienced developers can get tripped up by the simple things. In fact, I think that as you become more experienced the majority of your mistakes are the dumb and simple type. For example, last week I was trying to get a simple form to post to a script in a Codeigniter app but each time I hit the submit button I’d get insane errors and an empty $_POST array. Well, it turns out I’m not the only one so here’s how to fix that.

You ready for this? It’s super simple. You need to open your php.ini file and increase the maximum size of post requests. You may also need to mess with the maximum file upload size as well. I recommend turning on and setting error reporting to E_ALL when issues like this come up.

My issue was that I had a form that was uploading a minimum of 4 large images and I was exceeding not only the maximum upload size but the maximum $_POST array size (it was a real long form). I thought it was a Codeigniter issue. Turns out it’s just a simple PHP settings issue and easily fixed.

On most Ubuntu systems you can find your php.ini file at /etc/php5/apache2/php.ini. If all else fails put this into a file and navigate to it in your browser to see your PHP config:


I know, real remedial stuff. I’m embarrassed to admit that it tripped me up.

Highlights, Web development

« Version your API before it's too late Brite is a new Octopress theme »