kennmurrah
asked on
connection reset when uploading large files
Greetings.
I'm having a problem with my upload handler. If I send small files (under 1M or so), it works fine. if I send larger files, I get the following error in Firefox:
The connection was reset.
The connection to the server was reset while the page was loading.
When using Internt Explorer, the error is simply
The Page cannot be displayed.
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings
Do I have a problem with my php.ini settings? I've tried a few adjustments but can't find the magic solution.
Any ideas?
Thanks in advance.
I'm having a problem with my upload handler. If I send small files (under 1M or so), it works fine. if I send larger files, I get the following error in Firefox:
The connection was reset.
The connection to the server was reset while the page was loading.
When using Internt Explorer, the error is simply
The Page cannot be displayed.
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings
Do I have a problem with my php.ini settings? I've tried a few adjustments but can't find the magic solution.
Any ideas?
Thanks in advance.
ASKER
I'll try that, but the timeout occurs INSTANTLY ... so I'm not sure how that affects things.
ASKER
Just tried setting max_execution_time to a ridiculously high value, but once again, the error displayed immediately.
Check your upload_max_filesize
Gamebits
Gamebits
ASKER
upload_max_filezie set to 200M
post_max_size = 250M
post_max_size = 250M
OK! what about the script, is there any upload limit set within the upload script?
Gamebits
Gamebits
ASKER
Not that I can see ... here's the complete code:
<?php
if ($customer == "" || $contact == "" | $contact_email == "") {
print <<< END
<table width="500" border="0" cellspacing="3" cellpadding="3">
<tr>
<td width="65"><img border="0" src="UsseryLogo.jpg"> </td>
<td>
<h1><font size="+3" color="#990000"><i>Oops.</ i></font>< /h1>
</td>
</tr>
</table>
You must supply your name, your company's name and <br>
your email address when uploading files.<p>
Please click on the back button in your browser<br>
or (if you have Javascript enabled) click <a href="#" onClick="history.go(-1)">< /a>
<input type=button value="HERE" onClick="history.go(-1)">
to <br>return to the previous page.<p>
Thanks!<p>
END;
}
else {
$customer_trimmed = eregi_replace("[^[:alnum:] \.]","",$c ustomer) ;
$customer_shortened = substr($customer_trimmed,0 ,18);
$customer_trimmed = $customer_shortened;
$folder_name = $customer_trimmed . date("mdyHis");
$old_umask = umask();
mkdir('/home/upco/uploads/ ' . $folder_name, 0777);
//umask($old_umask);
$dest_dir = '/home/upco/uploads/' . $folder_name;
error_reporting(0);
$summary_info = "You have successfully uploaded the following file(s):<br>" ;
for ($i=0; $i<count($_FILES['userFile ']['name'] ); $i++)
{
$new_name = $_FILES['userFile']['name' ][$i];
$parsed_name = eregi_replace("[^[:alnum:] \.]","",$n ew_name) ;
$dest = $dest_dir . '/' . $parsed_name;
if (!file_exists ($dest)) {
copy($_FILES['userFile'][' tmp_name'] [$i], $dest) ;
$changepermissions = chmod($dest, 0777);
if ($_FILES['userFile']['size '][$i] > 0) {
$summary_info = $summary_info . "<tr><td>" . $_FILES['userFile']['name' ][$i] . "<td>" . $_FILES['userFile']['size' ][$i] . " bytes<p>" ;
}
}
}
$uploaded_file = $f['name'] ;
$email_subject = "$customer has uploaded a file";
$salesrep = $salesrep . ",kennphone@thebytebusines s.com";
$email_body = "$customer\n$contact\n$con tact_email \n\n$descr iption\n$d est_dir\n\ n";
mail("$salesrep", "$email_subject", "$email_body");
$email_subject = "Your File Has Been Received";
$email_body = "$contact :\n\n
Your file $uploaded_file has been received by Ussery Printing Company, and both your sales representative and customer service representative have been notified.\n\n
If we can be of further assistance, please call us at 972-438-8344.\n
Thank you.\n
Ussery Printing Company
3402 Century Circle
Irving, TX 75062
972-438-8344\n";
mail($contact_email, $email_subject, $email_body);
print <<<END
<table>
$summary_info
</table>
<p>If you need to upload more files, click <a href="index.html">here</a> <br>
to return to the Uploads Page. </p>
<P> If you have questions, please call your Sales Representative<br>
at 972-438-8344.
<p>
END;
$upload_info = "Customer: $customer\n\n
Contact: $contact
Contact email: $contact_email
Salesrep: $salesrep
$description";
$testfilename = $dest_dir . "/instructions.txt";
$testfile = fopen($testfilename, "a+");
$customer = $customer . "\r\n";
$contact = $contact . "\r\n";
fwrite($testfile, "Customer: $customer\r\n");
fwrite($testfile, "Contact: $contact\r\n");
fwrite($testfile, $description);
fclose($testfile);
}
?>
<?php
if ($customer == "" || $contact == "" | $contact_email == "") {
print <<< END
<table width="500" border="0" cellspacing="3" cellpadding="3">
<tr>
<td width="65"><img border="0" src="UsseryLogo.jpg"> </td>
<td>
<h1><font size="+3" color="#990000"><i>Oops.</
</td>
</tr>
</table>
You must supply your name, your company's name and <br>
your email address when uploading files.<p>
Please click on the back button in your browser<br>
or (if you have Javascript enabled) click <a href="#" onClick="history.go(-1)"><
<input type=button value="HERE" onClick="history.go(-1)">
to <br>return to the previous page.<p>
Thanks!<p>
END;
}
else {
$customer_trimmed = eregi_replace("[^[:alnum:]
$customer_shortened = substr($customer_trimmed,0
$customer_trimmed = $customer_shortened;
$folder_name = $customer_trimmed . date("mdyHis");
$old_umask = umask();
mkdir('/home/upco/uploads/
//umask($old_umask);
$dest_dir = '/home/upco/uploads/' . $folder_name;
error_reporting(0);
$summary_info = "You have successfully uploaded the following file(s):<br>" ;
for ($i=0; $i<count($_FILES['userFile
{
$new_name = $_FILES['userFile']['name'
$parsed_name = eregi_replace("[^[:alnum:]
$dest = $dest_dir . '/' . $parsed_name;
if (!file_exists ($dest)) {
copy($_FILES['userFile']['
$changepermissions = chmod($dest, 0777);
if ($_FILES['userFile']['size
$summary_info = $summary_info . "<tr><td>" . $_FILES['userFile']['name'
}
}
}
$uploaded_file = $f['name'] ;
$email_subject = "$customer has uploaded a file";
$salesrep = $salesrep . ",kennphone@thebytebusines
$email_body = "$customer\n$contact\n$con
mail("$salesrep", "$email_subject", "$email_body");
$email_subject = "Your File Has Been Received";
$email_body = "$contact :\n\n
Your file $uploaded_file has been received by Ussery Printing Company, and both your sales representative and customer service representative have been notified.\n\n
If we can be of further assistance, please call us at 972-438-8344.\n
Thank you.\n
Ussery Printing Company
3402 Century Circle
Irving, TX 75062
972-438-8344\n";
mail($contact_email, $email_subject, $email_body);
print <<<END
<table>
$summary_info
</table>
<p>If you need to upload more files, click <a href="index.html">here</a>
to return to the Uploads Page. </p>
<P> If you have questions, please call your Sales Representative<br>
at 972-438-8344.
<p>
END;
$upload_info = "Customer: $customer\n\n
Contact: $contact
Contact email: $contact_email
Salesrep: $salesrep
$description";
$testfilename = $dest_dir . "/instructions.txt";
$testfile = fopen($testfilename, "a+");
$customer = $customer . "\r\n";
$contact = $contact . "\r\n";
fwrite($testfile, "Customer: $customer\r\n");
fwrite($testfile, "Contact: $contact\r\n");
fwrite($testfile, $description);
fclose($testfile);
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
more info here
http://ca3.php.net/manual/en/function.set-time-limit.php
Gamebits