Hello I need to send .doc and .pdf on mail using my php form. my code is here Form code <form action="contactform.php" class="form-horizontal" method="post" enctype="multipart/form-data"> <input type="file" name="uploaded_file" maxlength="500" allow="text/*"> <input type="hidden" value="thank" name="message" /> <?php $url_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; ?> <input type="hidden" value="<?php echo $url_link; ?> " name="url" /> <button type="submit" class="btn btn-success" style="width:100%;">submit</button> PHP: PHP Code <?php $errors = ''; $myemail = 'mymail.mymail.com'; $uploaded_file = $_POST['uploaded_file']; { $to = $myemail; $email_subject = "my pdf file: $uploaded_file"; $email_body = "You have received a new message. ". "Here are the details:\n file: $uploaded_file:" ; $headers = "From: $e_mail\n"; $headers .= "Reply-To: $e_mail"; } ?> PHP: But i am not able get attached file on my mail
The better way would be to use / include the PHPMailer-script. Take a look at this Stackoverflow-thread: http://stackoverflow.com/questions/12301358/send-attachments-with-php-mail
Files are not sent as part of $_POST, they are sent as part of $_FILES. http://php.net/manual/en/reserved.variables.files.php To attach the file to an e-mail you'd need to construct that mail as multi-part and uuencode the files contents... There's a halfway decent article about doing that here: http://webcheatsheet.com/php/send_email_text_html_attachment.php Hope that helps.