MARTIN Damien
MARTIN Damien

Reputation: 1026

PHP upload fail (empty $_FILES)

I have a common problem in PHP : My $_FILES array is empty when files are too big.

php.ini :

max_execution_time = 300000
max_input_time = 600000000
memory_limit = 5100MB
post_max_size = 5000MB
upload_max_filesize = 5000MB

The file :

Trouve.tar : 910Mo

Configuration values are huge but I want to be sure that the script have the time and the memory to do the upload.

So, the authorized size is bigger than the file size, but I have the same error than other people (like problem with uploading the images with php file upload for exemple)

Have I missed some configuration setting ?

Upvotes: 2

Views: 6320

Answers (4)

egg
egg

Reputation: 1756

Instead of MB use M

memory_limit = 5100M

post_max_size = 5000M

upload_max_filesize = 5000M

Upvotes: 3

Chuck Burgess
Chuck Burgess

Reputation: 11574

The problem is your post_max_size is the same size as upload_max_filesize which will cause the $_FILES array (and $_POST) to be empty. If you up the limit on the post_max_size, the $_FILES array will no longer be empty.

EDIT: Not sure why the negative vote. While it may not apply exactly in this case, it is worth mentioning. This is exactly what php.net says: http://www.php.net/manual/en/ini.core.php#ini.post-max-size.

If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty.

Upvotes: 6

hahaha
hahaha

Reputation: 476

Check your upload_limit in your php.ini settings.

In your html form tag, do not forget to put this: enctype="multipart/form-data"

Upvotes: 3

scoffey
scoffey

Reputation: 4688

Check you web server limits in addition to the php.ini configuration.

For example, you'll probably have to increase the LimitRequestBody if you're using Apache or the client_max_body_size if you're using nginx.

When an HTTP request is larger that the limit accepted by the web server, it returns an HTTP response with status: 413 Request Entity Too Large.

Upvotes: 1

Related Questions