I just went through this answer, as how to send a file in PHP using PHPMailer. I have the following HTML code:
<form action="./php/send-file.php" method="post" enctype="multipart/form-data">
<input type="file" name="files" id="filer_input" multiple="multiple">
<input type="submit" value="Submit">
</form>
PHP code as below:
require_once('class.phpmailer.php');
$email = new PHPMailer();
$email->From = 'gautam@webmunky.com';
$email->FromName = 'Your Name';
$email->Subject = 'Message Subject';
$email->AddAddress( 'gautam@webmunky.com' );
<!-- $file_to_attach = $_FILES['files']; -->
$email->AddAttachment( $_FILES['files']['tmp_name'],
$_FILES['files']['name'] );
return $email->Send();
I believe I am making a mistake in the below two lines of code:
<!-- $file_to_attach = $_FILES['files']; -->
$email->AddAttachment( $_FILES['files']['tmp_name'],
$_FILES['files']['name'] );
but I am not sure. How can I send my file using the above PHP code?