Hi
I am preapring a website form where the resume needed to be uploaded and it should send an email to me along with upload as attachment. Please let me know the error in this below forms:
== HTML Form:
<form method="post" name="mailform" action="emailnew.php">
<table width="200" border="0" cellspacing="0">
<tr>
<td width="62">Name:</td>
<td width="134">
<input name="name" type="text" id="name">
</td>
</tr>
<tr>
<td>Email:</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td valign="top">Message:</td>
<td><textarea name="body" cols="45" rows="10"></textarea></td>
</tr>
<tr>
<td valign="top">Select Resume:</td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="1000" />
Upload File: <input name="uploadedfile" type="file" /> <br /></td>
</tr>
</table>
<br>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</form>
== PHP Code:
<?php
$target_path = "./resupload/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$name = $_POST['name'];
$email = $_POST['email'];
$body = $_POST['body'];
if ($name != "" AND $email != "" AND $body != "") {
$sendto = "test@test.com";
$from ="Web Resume";
$subject = "Resume Uploaded in Website";
$message = "This is a message from your site
From: $name
Email: $email
Message: $body";
mail("$sendto", "$subject", "$message");
echo "Your message was sent";
if (is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
?>
Please let me know the changes to be done for my php file to make sure that upload file send attachment and deletes from server (web-hosting directory also)