2

I have a really odd problem. I am using an upload form to upload videos. Sometimes I have to try twice to upload a file so I know it works but these files take a long time to upload so I don't want the end-user getting mad if the process fails. Also, this works 100% of the time on my test machine so I am thinking there is a config problem.

The file is 330mb and I set upload_max_filesize and post_max_size to 500mb. The max_execution_time and max_input_time are set to 60000 for testing purposes. memory_limit is what I think may be the problem. It is set to 128mb. Does it need to be higher to have a consistent upload success rate? Anybody know of any other problems that could cause things to go wrong?

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
Scarface
  • 3,845
  • 7
  • 41
  • 71

1 Answers1

1

You're right in assuming memory_limit is your culprit.

Taken from php.net.

post_max_size (int)
Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize.

If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size. When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used. (...)

Frankie
  • 24,627
  • 10
  • 79
  • 121
  • 1
    Wouldn't it be dangerous to set my memory limit greater than 500mb (that is what I set my post_max_size and upload limit to)? I read that excerpt before and I felt like I need clarification on that. – Scarface Jul 07 '11 at 17:00
  • Does a file really need that much memory just to make a simple transfer from folder to another (move_uploaded_file)? – Scarface Jul 07 '11 at 17:07
  • @Scarface do refer to this great answer by @Artefacto http://stackoverflow.com/questions/3651141/in-php-settings-should-memory-limit-upload-max-filesize#answer-3651195 – Frankie Jul 07 '11 at 17:14
  • That is a good answer, but he doesn't recommend or comment on what memory limit would be appropriate for a file upload size. In my case, the largest file I will receive is about 400mb even though I set it to 500mb. How do you calculate what a good memory limit would be? Clearly I am having issues with my current limit since move_uploaded_file sometimes seems to fail. – Scarface Jul 07 '11 at 17:33
  • @Scarface I've look around, done some searching, and unfortunately wasn't able to find anything that exactly described why or how to achieve an optimal balance. This optimal balance, though, should probably be asked as a new question. – Frankie Jul 07 '11 at 18:34