Username_null
Username_null

Reputation: 1315

can server timeout be controlled by code?

I have used a tutorial to create a PHP script to upload files to a server. It works beautifully for images and small files < 10mb but over that size it fails. I believe that this may be due to a server timeout. The question is, if I am correct in my assumption is there a way to tell the server to wait until the file has uploaded?

Of course there may be another issue I haven't thought of, according to the script I have the large uploads aren't producing an error and the "success" text is displayed!

Any helpful advice would be appreciated :)

Upvotes: 6

Views: 2633

Answers (6)

Bil
Bil

Reputation: 543

If you're using PHP as an Apache module and previous answers doesn't work, you can look at Apache timeout but it's not advisable.

Upvotes: 0

Lawrence Cherone
Lawrence Cherone

Reputation: 46610

make sure your allowed over 10mb for uploads http://php.net/manual/en/features.file-upload.errors.php

then with php

set_time_limit(0);

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

Upvotes: 1

NA.
NA.

Reputation: 6579

In PHP there's a function called set_time_limit() which you can use to set how long it'll take before PHP terminates due to running to long. Be careful with it though because setting it to 0 can leave php processing waiting around forever and eat up your server resources.

You can also set this directive in php.ini or from apache .htaccess files.

There is also max_input_time in php.ini

Upvotes: 2

user680786
user680786

Reputation:

This directives can be useful:

  • upload_max_filesize
  • max_execution_time

This directives can be changed in php.ini or via function ini_set.

Upvotes: 1

Adam Hopkinson
Adam Hopkinson

Reputation: 28795

You can set the timeout using set_time_limit($seconds)

If you set $seconds to 0, the server won't time out - but use this very carefully!

Upvotes: 3

Related Questions