PDA

View Full Version : Upload File - Time Out!


Jabbamonkey
09-05-2002, 09:19 PM
I am using a php web form to upload files to my server, and send them via email. Well, some of my users are upload large files and the page keeps timing out...

Fatal error: Maximum execution time of 30 seconds exceeded in D:\SERVER\123\folder\form_confirm.php on line 2

How do I avoid this timeout?

Jabbamonkey

mordred
09-05-2002, 11:44 PM
That will be hard to deal with - that's php.ini setting, and tells the script to abort if it's running too long, to prevent taking up processes and memory forever.

You can try to dynamically modify this setting with ini_set(), look in the manual for the order of the parameters. However, if you're on a shared server, you may be prohibited to use this function, so I wouldn't expect that to work anywhere.

On the clientside, you can set the maxlength attribute and hope that the user's browser restricts the file's size by that. But really, educate your users that there is something that's called FTP and is exactly suited for this purpose.

Jabbamonkey
09-06-2002, 12:40 AM
I tried the following line...

ini_set(mssql.timeout, "600");

... and the script worked fine. But, since I'm on a DSL connection, I've never recieved the error (someone on a slower connection tested the old script, and send me the error). How do I know if this worked correctly? Can I test it by tweeking the script
somehow?

if ($test=='ok') { echo "timeout $timeouttime"; }

Also, does the line "mssql.timeout" refer to the msql database? The script I'm using doesn't refer to the databases at all ... is there another line for just straight php?

Jabbamonkey

mordred
09-06-2002, 09:03 AM
No, I rather meant the "max_exectution_time" setting, not the mssql.timeout (since if you don't use databases, how should it relate to your problem?). You can also use set_time_limit (http://www.php.net/manual/en/function.set-time-limit.php) to change the number of seconds a script is permitted to run.

Though I doubt that it all will help if your user is running on a really slow connection and tries to move 1 GB to your server...

Jabbamonkey
09-06-2002, 05:06 PM
Now I'm running into another problem....

First, let me explain what the script does. There is a webform that allows a user to enter several fields of information, including several "browse-file" fields. When the user hits submit, the form sends an email to an email address containing all the information submitted, and whatever attachments there were. If the page didn't timeout (as mentioned before), this script worked fine.

Well, when I add the line...

ini_set(max_exectution_time, "600");

...to the script, the page looks fine from the user's end (no timeout error). BUT, when I recieve the email, the attachments are now broken (i.e. broken images, corrupt zip files).

I checked the MIME settings of the recieved email and saw all the attachment info, but no data...

------_=_NextPart_001_01C255B6.834A3423
Content-Type: image/pjpeg;
name="fpx02572.jpg"
Content-Transfer-Encoding: base64
Content-Description: fpx02572.jpg
Content-Disposition: attachment;
filename="fpx02572.jpg"

####DATA WOULD GO HERE####

For some reason, the page isn't submitting this data anymore... Any ideas?