too long

i want to upload a local file via PHP to Google Drive. If I upload a small file (<5MB) everything is working. If I want to upload a larger file I get a "Fatal error: Maximum execution time of 30 seconds exceeded". I can set the max_execution_time in my php.ini on a very high value but it seems to be a bad solution. If I use "set_time_limit(seconds);" I can't upload more files simultaneously (I don't know why).

So my question is how to upload a large file without changing my php.ini to a bad execution time. How is that supposed to solve in PHP? I would like to use just a simple CURL cli command but that does not work with Google Drive because CURL can't support Oath.

This a bad idea to use a simple PHP code to upload a very large file.

You should use Javascript to upload large files because it's using AJAX methods. Also, it will allow you to display a progress bar.

I did a little research. Here is some nice scripts using jQuery : http://designscrazed.org/html5-jquery-file-upload-scripts/

Or another script which not use jQuery (I don't if it's a good one) : http://igstan.ro/posts/2009-01-11-ajax-file-upload-with-pure-javascript.html

Good luck !

Setting the max_execution_time with set_time_limit is the right solution. If your script takes more than 30 seconds to upload the file, it will run more than 30 seconds.

set_time_limit(600); //File upload should not take longer than 10 minutes
do_your_file_upload();
set_time_limit(30); //Change it back to 30 seconds for further processing

I can't upload more files simultaneously

Can you specify what you mean?

If you cannot reach your PHP-Script while the other one runs, it is often because of PHP session management. When you start the session with session_start PHP (creates and) opens the session file and locks it for writing. The file will be locked until your scripts calls session_write_close or the script execution ends. To work with two or more sessions simultaneously, you have to call session_write_close:

session_start();
//do stuff
session_write_close();

set_time_limit(600); //File upload schould not take longer than 10 minutes
do_your_file_upload();
set_time_limit(30); //Change it back to 30 seconds for further processing

session_start();
//do more stuff
session_write_close();