How can I send an email with an attachment in php?

Irish

New member
I'm new in PHP and I have a problem sending email with attachment.
I already have this code but the attachment part is still not working.
I send email but there's no attachment included in the mail. I still don't know how to do that.
Can someone please help me? I need your advise badly. Thanks in advance.


<body>
<form enctype="multipart/form-data" action="email.php" method="POST">
<table width="500px">
<tr><td width="20%">To : </td>
<td><input type="text" name="to" /></td></tr>
<tr><td>From :</td><td><input type='text' name="from" /></td></tr>
<tr><td>Subject :</td><td><input type='text' name="sub" /></td></tr>
<tr><td>Message :</td><td><textarea name="message"></textarea></td></tr>
<tr><td><input type="hidden" name="MAX_FILE_SIZE" value="100000" /></td></tr>
<tr><td>Choose a file to upload: <input name="uploadedfile" type="file" /><br/></td>
</tr>

<tr><td></td><td><input type="submit" value=" Send " /></td></tr>

<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
}

?>

Your help is really much appreciated.
 
Back
Top