Posts

Showing posts from August, 2012

PHP file upload data not post

If you use the normal PHP POST file upload method mentioned in official PHP page, chances are you may get empty $_POST or $_FILES array. In my case, I am creating a page that allow people to upload a CSV file (can be a very large file, e.g. >10M), then everything is following what is mentioned in the official PHP page.  However, the $_POST and $_FILES do not have any data when I print_r() it. Probably it is the main reason: your upload file size is too big , a.k.a: Size matters . Here are some suggestions: 1. Make your MAX_FILE_SIZE bigger: <input type="hidden" name="MAX_FILE_SIZE" value="9000000000" /> 2. In your PHP code, add this: ini_set('upload_max_filesize', '128M'); ini_set('post_max_size', '128M'); If it does not work, add these in your php.ini file instead of inside your PHP code. post_max_size = 128M upload_max_filesize = 128M  Hope it helps someone, and for my reference.

PHP error_reporting exclude notice and deprecated

For information to anyone who want to exclude more than one option of  error_reporting in PHP, use this: error_reporting(E_ALL ^ (E_NOTICE | E_DEPRECATED | E_USER_DEPRECATED)); Use () and | to pick errors that you DON'T want to show. Source:  http://stackoverflow.com/questions/2803772/turn-off-deprecated-errors-php-5-3