I have this code. But it's not working. Please give me some code in PHP, so that I can attach a file using an HTML form and send it to some email address. The file type (I want .zip only) and size (I want 2 MB max) needs to be checked before emailing.
Here goes the code:
$req_id = time();
$new_file="public_html/uploads/" . $req_id . ".zip";
if (($_FILES["file"]["type"] == "application/zip") && ($_FILES["file"]["size"] < 10000000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Fatal Error! Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"], $new_file);
}
}
else
{
Print "<strong>There was an error while processing your request. Your query for quotation is not submitted successfully.</strong><br /><font color='red'>ERROR!<br>The attached file is not invalid. Either the file size is greater than 10 MB or the file type is not ZIP. Please check and try again.</font><p> </p><p> </p><p> </p><p> </p>";
}