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.

Comments

Popular posts from this blog

TCPDF How to show/display Chinese Character?

How to fix fancy box/Easy Fancybox scroll not work in mobile

Wordpress Load balancing: 2 web servers 1 MySQL without any Cloud services