2

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 ?

7
  • Seriously, is that 910 megabytes? I didn't look it up, but PHP likely has some builtin hard limits. Commented Jan 17, 2011 at 15:20
  • Just to clarify, it works with small files? Commented Jan 17, 2011 at 15:22
  • @Naatan Yes it works without any problems. Commented Jan 17, 2011 at 15:24
  • Single file? Must it be a form request? Else capturing a PUT request might make sense. Commented Jan 17, 2011 at 15:28
  • @mario Yes it is a single file from a form request. I didn't know PUT request, I'll try this. Commented Jan 17, 2011 at 15:32

4 Answers 4

6

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Negative vote was not mine. Sorry. I'll try what you said when I will have time. For the moment I gave up. Thank you.
@ChuckBurgess Its a true fact :)
3

Instead of MB use M

memory_limit = 5100M

post_max_size = 5000M

upload_max_filesize = 5000M

Comments

3

Check your upload_limit in your php.ini settings.

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

1 Comment

Thank you hlegius but I cant find "upload_limit" in my php.ini and seems to not exists : google.fr/…. My form works with small files (until approximatively 300Mo), so yes "enctype="multipart/form-data"" is set.
1

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.

2 Comments

LimitRequestBody has been set to 0 (no limit) and the result script is shown (no server error for a "too large file").
Make sure these settings are OK in the php.ini or the virtual host configuration file: upload_max_filesize, post_max_size, max_execution_time and max_input_time. What's the output when debugging: var_dump($_FILES) and var_dump($_REQUEST)? You may also try activating LogLevel debug in Apache to check any problems the server logs when you upload the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.