0

I have big trouble with file uploads with php. My own tests are successful but my colleague is telling me that he cannot update "larger" (ca. 5mb) files.

Phpinfo says: - max_execution_time 30 - memory_limit 32 Mb - post_max_size 8 Mb - upload_max_filesize 10 Mb

Is it better to use FTP? The problem is that I cannot change these settings at my webhoster.

2
  • based on those settings files around 5MB should upload just fine. Commented Mar 11, 2010 at 20:30
  • But it isn't fine :( My colleague cannot update a file greater than 5 Mb. It took a long time with showng the page and then it comes up an Internal Server Error. Commented Mar 11, 2010 at 20:37

4 Answers 4

1

Your script will not work on production because your max_execution_time is set to 30 seconds. This means that you have just 30 sec to upload your file under your server. If you don't have a T1 Internet connection, you won't be able to upload the file. In your upload script try to run the following:

set_time_limit(0);

This will disable max_execution_time definition, letting any connection speed user upload the file using your script.

more info at http://php.net/manual/en/function.set-time-limit.php

regards.

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

1 Comment

This was one possibility I was thinking about, but current test was negative. Again a Internal Server Error. Maybe I need to use FTP
1

Why have you no error handling to identify why your colleague cannot upload the file? Is it the execution time? is it the memory limit? Is it the max post size? Is it the upload size?

Have you checked to see what happens when he uploads a file? At what point does it fail?

The PHP post_max_size is irrelevant if the webserver has a smaller setting - have you checked?

There are lots of reasons why an HTTP upload might not work, but if the answer to your question is FTP, then you're asking the wrong question.

C.

3 Comments

How can I handle such errors? My colleague is uploading a file of 5Mb or more and then it takes a long time where the server is not responding (Caused by the upload, I guess) and then an Internal Server Error comes up. The PHP post_max_size is irrelevant if the webserver has a smaller setting - have you checked? PHPInfo prints out: 8Mb
You didn't say "it takes a long time" before. Longer than 30 seconds? Again the setting in PHP for post_max_size is irrelevant if your webserver has a lower setting - phpinfo only reports the PHP setting - NOT the webserver setting
I have changed the settings for max_input_time and max_execution_time to unlimited but when the upload takes longer than 2 minutes, the internal server error comes up. I am asked for support by the webhoster, it seems that the webser has lower settings as you said.
0

I have asked support for the settings for max_execution_time and max_input_time and this are set to 120 as maximum. So all uploads taking longer then 2 minutes ending up in an Internal Server Error.

Comments

-1

You may be able to change those settings using ini_set()

2 Comments

No you can't. Only on a PHP_INI_PERDIR basis. See: php.net/manual/en/ini.list.php
My Webhoster is strato.de and as far as I know he does not offer anything like php_ini settings per folder.

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.