php - How to include attachment file using my form to email? -


i have form:

<form id='contactus' action='send.php' method='post' enctype="multipart/form-data" accept-charset='utf-8'> <fieldset> <legend>my form</legend> <table><tbody> <tr valign="top"> <td nowrap="nowrap" style="text-align: right;"><label for='name' >name: </label></td> <td><input type='text' name='name' id='name' value=''/></td></tr> <tr valign="top"> <td nowrap="nowrap" style="text-align: right;"><label for='email' >email: </label></td> <td><input type='text' name='email' id='email' value=''/></td></tr> <tr valign="top"> <td nowrap="nowrap" style="text-align: right;"><label for='link' >link: </label></td> <td><input type='text' name='link' id='link' value=''/></td></tr> <tr valign="top"> <td nowrap="nowrap" style="text-align: right;"><label for='subject' >subject: </label>  </td><td><input type='text' name='subject' id='subject' value=''/></td></tr> <tr valign="top"> <td nowrap="nowrap" style="text-align: right;"><label for='description' >description:  </label></td> <td><textarea rows="10" cols="50" name='description' id='description'></textarea> </td></tr> <tr valign="top"> <td nowrap="nowrap" style="text-align: right;"><label for='photo' >photo: </label></td> <td><input type="file" name='photo' id='photo' /></td></tr> </tbody></table> <td nowrap="nowrap" style="text-align: center;"><input type='submit' value='send' /></td> </fieldset> </form> 

and 'send.php' is

<?php if(isset($_post['email'])) {  $email_to = "mymail@gmail.com"; $subject = $_post['subject']; $name = $_post['name']; $email = $_post['email']; $link = $_post['link']; $description = $_post['description']; $photo = $_post['photo'];  $email_message .= "name: ".($name)."\n"; $email_message .= "email: ".($email)."\n"; $email_message .= "link: ".($link)."\n"; $email_message .= "subject: ".($subject)."\n"; $email_message .= "description: ".($description)."\n"; $email_message .= "photo: ".($photo)."\n";  // create email headers 'x-mailer: php/' . phpversion(); @mail($email_to, $subject, $email_message); } header("location: thank-you.html"); ?> 

my question is:

1) works good.. except 'photo', know suppose attachment. don't know how make it?

2) , how can see bold when receive email?

$email_message .= "name: ".($name)."\n";

emp: name: john

i have try didn't work.

$email_message .= "<b>name: </b>".($name)."\n"; $email_message .= "<b>email: </b>".($email)."\n"; $email_message .= "<b>link: </b>".($link)."\n"; $email_message .= "<b>subject: </b>".($subject)."\n"; $email_message .= "<b>description: </b>".($description)."\n"; 

thanks in advance

use $_files super global array instead of $_post handle files.

 $photo = $_files['photo']['name'];     ...   $email_message .= "photo: ".$photo."\n"; 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -