views:

113

answers:

4

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.

A: 

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

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

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.

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

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.

symcbean
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
Develman
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
symcbean
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.
Develman
A: 

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.

Develman