错误使用PHPMailer发送附件电子邮件和插入数据库

时间:2014-10-01 02:15:04

标签: php mysql phpmailer

数据正在提交给simpankarir.php,然后数据可以存储在数据库中,但数据(uploadfile)无法将附件文件发送到电子邮件。我使用phpmailer ..任何人都可以帮我解释代码错在哪里..

simpankarir.php

<?php

include"../log/in/ngoneksi/konek.php";
include"thumb.php";

include('PHPMailer-master/class.phpmailer.php');

$lokasi_file = $_FILES['fupload']['tmp_name'];
$tipe = $_FILES['fupload']['type'];
$nama_file = $_FILES['fupload']['name'];
$acak = rand(1,99);
$nama_file_unik = $acak.$nama_file;

Uploadkarir($nama_file_unik);

mysql_query ("INSERT INTO karir(nama, email, file, posisi, telp) VALUES ('$_POST[nama]', '$_POST[email]', '$nama_file_unik', '$_POST[posisi]', '$_POST[telp]')");


$email = new PHPMailer();
$email->From      = $_POST['email'];
$email->FromName  = $_POST['nama'];
$email->Subject   = 'Hai';
$email->Body      = 'test';
$email->AddAddress( 'gusti@sabas.co' );

$file_to_attach = $_FILES['fupload']['tmp_name'];

$email->AddAttachment( $file_to_attach , $_FILES['fupload']['name'] );
return $email->Send(); 


?>

thumb.php

<?php
error_reporting(0);
function Uploadkarir($fupload_name){
  //direktori banner
  $vdir_upload = "file/";
  $vfile_upload = $vdir_upload . $fupload_name;

  //Simpan gambar dalam ukuran sebenarnya
  move_uploaded_file($_FILES["fupload"]["tmp_name"], $vfile_upload);
}
function Uploadkarir2($fupload_name){
  //direktori banner
  $vdir_upload = "file/";
  $vfile_upload = $vdir_upload . $fupload_name;

  //Simpan gambar dalam ukuran sebenarnya
  move_uploaded_file($_FILES["fupload2"]["tmp_name"], $vfile_upload);
}
?>

form.php的

<form data-toggle="validator" role="form" name="formkarir" id="formkarir" action="simpankarir.php" method="post" enctype="multipart/form-data"> 
<input type="file" id="fupload" name="fupload">
<button type="submit" class="btn btn-primary btn-lg hidden-xs" id="button-resume"> Kirim Resume Saya</button>
</form>   

0 个答案:

没有答案