Log in

View Full Version : submit a attachment via form



madu
07-28-2010, 05:39 AM
Hi,

In my site I have a form which anyone can submit details via e-mail.


Since I want to get more details, I leave a space to upload a document.then visitor can browse & upload the details.


Please can anyone tell me how can I receive the uploaded document as a e-mail attachment???
This is my code. please help me by modifying my code to receive the document as e-mail attachment.

code from contact.html

<form method="post" action="sendeail.php">
Your Name: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br />
Please attach your details:<br>
<input type="file" name="attachment" size="23">
<br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<br />
<input type="submit" value="Send Mail" />
<br />
</form>

code from sendeail.php

<?php

$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];

$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n

Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n";
$from = "From: $visitormail\r\n";

mail("isc_madusanka@yahoo.com", $subject, $message, $from);

?>
please help me. thank you...................

prasanthmj
07-28-2010, 07:41 AM
Accepting file uploads in a form requires several steps. See the page below for some examples:
create PHP email form with file attachment (http://www.html-form-guide.com/email-form/php-email-form-attachment.html)