Задача, с заявки на сайте отправить форму на нужный меил через smtp клиент хоста. К сообщению должны быть прикреплены файлы и текст. На данном этапе у меня получилось отправить текст. Но файлы вовсе не отображаются. Может быть ошибка в самом коде?
if(isset($_FILES['profileImage'])){
$errors= array();
$file_name = $_FILES['profileImage']['name'];
$file_size = $_FILES['profileImage']['size'];
$file_tmp = $_FILES['profileImage']['tmp_name'];
$file_type = $_FILES['profileImage']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['profileImage']['name'])));
$expensions= array("jpeg","jpg","png","pdf");
if(in_array($file_ext,$expensions)=== false){
$errors[]="extension not allowed, please choose a PDF, JPEG or PNG file.";
}
if($file_size > 2097152) {
$errors[]='File size must be excately 2 MB';
}
if(empty($errors)==true) {
move_uploaded_file($file_tmp,"uploads/".$file_name); //The folder where you would like your file to be saved
echo "Success";
}else{
print_r($errors);
}
}
// PHPMailer script below
$parameters = $_REQUEST['parameters'];
$from = $_REQUEST['from'];
$insta = $_REQUEST['Insta'];
$age = $_REQUEST['age'];
$user_mail = $_REQUEST['mail'];
$user_name = $_REQUEST['user_name'] ;
require("phpmailer/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "";
$mail->SMTPAuth = true;
$mail->Username = ""; // SMTP username
$mail->Password = ""; // SMTP password
$mail->addAttachment("upload/".$file_name);
$mail->From = $user_mail;
$mail->SMTPSecure = 'ssl';
$mail->Port = ; //SMTP port
$mail->addAddress("");
$mail->Subject = "You have an email from a Join Us!";
$mail->Body ="
Name: $user_name
Age: $age
Parameters: $parameters
Country&City: $from
Email: $user_mail
Instagram: $insta";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "<script>alert('Message has been sent')</script>";
?>