[ASK]PHPMailer mengirimkan attachment dengan php

Discussion in 'Desain Web dan Programming' started by artayoga, 1 Oct 2014.

Thread Status:
Not open for further replies.
  1. artayoga

    artayoga New Member

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Tuan mohon bantuannya.. saya nemuin kesulitan lg nie ..
    misalkan saya punya form untuk upload file.. pada saat upload tersebut saya ingin kesimpen dalam database beserta ke direktori file yang dituju dan file tersebut terkirim ke email tertentu berupa attachment.. skr saya mentoknya cuman salah satu aja yg jalan. jd klo datanya kesimpan dlm database, tp attachment emailnya gak jalan.. begitu jg sebaliknya.. mohon bantuannya, saya menggunakan phpmailer..

    ini script simpan.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', '$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( 'XXXXXXX' );

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

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



    ?>

    [B]ini script thumb.php : [/B]

    <?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);
    }
    ?>

    mohon bantuannya yaa
     
Loading...
Thread Status:
Not open for further replies.

Share This Page

Loading...