I am using this code as a mail form where a user can attach a file and it gets emailed. I was wondering what code I can add to limit the file size of the attachments to maybe 5 MB. I am using code from this ShotDev.Com Tutorial. Thanks.
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?
$strTo = $_POST["txtTo"];
$strTo = "aziola@yahoo.com";
$strSubject = $_POST["txtSubject"];
$strMessage1 = ($_POST["txtrar"]);
$strMessage2 = ($_POST["txtDescription"]);
$strMessage3 = ($_POST["coname"]);
$strMessage4 = ($_POST["address1"]);
$strMessage5 = ($_POST["address2"]);
$strMessage6 = ($_POST["city"]);
$strMessage7 = ($_POST["state"]);
$strMessage8 = ($_POST["zip"]);
$strMessage9 = ($_POST["country"]);
$strMessage10 = ($_POST["phone"]);
$strMessage11 = ($_POST["fax"]);
//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));
$strHeader = "";
$strHeader .= "From: ".$_POST["txtFormName"]."<".$_POST["txtFormEmail"].">\nReply-To: ".$_POST["txtFormEmail"]."";
$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-type: text/html; charset=utf-8\n";
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $strMessage."\n\n";
$strHeader .= $strMessage1." \n\n ";
$strHeader .= $strMessage2."\n\n";
$strHeader .= " <br> <br> Company Name: \n\n ";
$strHeader .= $strMessage3."\n\n";
$strHeader .= " <br> <br>Address1: \n\n ";
$strHeader .= $strMessage4."\n\n";
$strHeader .= " <br> <br>Address2: \n\n ";
$strHeader .= $strMessage5."\n\n";
$strHeader .= " <br> <br>City: \n\n ";
$strHeader .= $strMessage6."\n\n";
$strHeader .= " <br> <br>State: \n\n ";
$strHeader .= $strMessage7."\n\n";
$strHeader .= " <br> <br>Zip: \n\n ";
$strHeader .= $strMessage8."\n\n";
$strHeader .= "<br> <br>Country: \n\n ";
$strHeader .= $strMessage9."\n\n";
$strHeader .= " <br> <br>Phone: \n\n ";
$strHeader .= $strMessage10."\n\n";
$strHeader .= " <br> <br>Fax: \n\n ";
$strHeader .= $strMessage11."\n\n";
//*** Attachment ***//
if($_FILES["fileAttach"]["name"] != "")
{
$strFilesName = $_FILES["fileAttach"]["name"];
$strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
$strHeader .= $strContent."\n\n";
}
$flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "Mail send completed.";
}
else
{
echo "Cannot send mail.";
}
?>
</body>
</html>
<!--- This file download from www.shotdev.com -->