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>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>";
  }

no. i want to upload it from an html form and then email it. ur code is not doing that. also, where to find that class.email.php file? i need and html form with file input box, which file will be emailed to an email id.

create a form with an file input type and then my script will automatically read the uploaded files and send them to an email address. if you want to use an id, you will have to query the database and get the email and then have it put that email into the $email->to($email); function. i have used this to do what you are asking exactly so i know it works.

the class.email.php is attached to my post in that thread.

This question has already been answered. Start a new discussion instead.