Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > แปลงข้อมูล PDF แล้วแนบไฟล์ส่ง E-mail ด้วย function sendmail() ครับ



 

แปลงข้อมูล PDF แล้วแนบไฟล์ส่ง E-mail ด้วย function sendmail() ครับ

 



Topic : 036428



โพสกระทู้ ( 35 )
บทความ ( 0 )



สถานะออฟไลน์




มี2คำถามครับ
1.ตอนนี้ศึกษาเรื่องแปลงเป็น PDF อยู่ครับ
โดยทำตาม



แต่ติดปัญหาขึ้น error ดังนี้ครับ (ก็อบจากลิงค์ไม่ได้แก้ไรเลย นอกจาก require('../fpdf16/fpdf.php');)
Warning: fopen(MyPDF/MyPDF.pdf) [function.fopen]: failed to open stream: No such file or directory in C:\AppServ\www\SLAND\fpdf16\fpdf.php on line 1044
FPDF error: Unable to create output file: MyPDF/MyPDF.pdf
ควรทำอย่างไรดีครับ

2.ที่ผมต้องการดังนี้ครับ
มีข้อมูลหน้าสมัครสมาชิก พอกด submit แล้วข้อมูลเข้าฐานข้อมูล และแปลงเป็นไฟล์ PDF แล้วส่งไปเมลล์ที่ต้องการ
ควรเขียนอย่างไรดีครับ

สวัสดีปีใหม่ ขอบคุณครับ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-01-02 12:17:19 By : crd7 View : 5008 Reply : 10
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ตรวจสอบดู path และ permission ของโฟเดอร์ที่จะ write pdf ด้วยครับ






Date : 2010-01-02 18:07:11 By : webmaster
 


 

No. 2



โพสกระทู้ ( 35 )
บทความ ( 0 )



สถานะออฟไลน์


ได้แล้วครับ สร้าง Dir MyPDF เพิ่ม

ขอบคุณครับ
Date : 2010-01-02 18:26:46 By : crd7
 

 

No. 3



โพสกระทู้ ( 34 )
บทความ ( 0 )



สถานะออฟไลน์


error เหมือนกันเลยค่ะ แต่งงว่าสร้าง dir MyPDF คืออะไรเหรอค่ะ หมายถึงสร้างไฟล์ PDF ชื่อ MyPDF รึป่าว ช่วยหน่อยค่ะ เพิ่งศึกษาเรื่องนี้ยังไม่ค่อยรู้เรื่อง
Date : 2010-01-20 16:53:14 By : sitorn2170
 


 

No. 4

Guest


ใครรู้ วิธีรีไซส์ PDF มั่งคะ
Date : 2010-03-09 16:21:26 By : link
 


 

No. 5



โพสกระทู้ ( 71 )
บทความ ( 0 )



สถานะออฟไลน์


ตกลงทำให้มันส่งเมลล์ได้มั๊ยคะ ทำไงอ่ะ บอกทีค่ะ
Date : 2010-06-14 17:10:40 By : mostgirls
 


 

No. 6



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code (PHP PDF - Export to PDF and Send Email Attachment)
<html>
<head>
<title>ThaiCreate.Com PHP PDF</title>
</head>
<body>

<?php
require('fpdf.php');

class PDF extends FPDF
{
//Load data
function LoadData($file)
{
	//Read file lines
	$lines=file($file);
	$data=array();
	foreach($lines as $line)
		$data[]=explode(';',chop($line));
	return $data;
}

//Simple table
function BasicTable($header,$data)
{
	//Header
	$w=array(30,30,55,25,20,20);
	//Header
	for($i=0;$i<count($header);$i++)
		$this->Cell($w[$i],7,$header[$i],1,0,'C');
	$this->Ln();
	//Data
	foreach ($data as $eachResult) 
	{
		$this->Cell(30,6,$eachResult["CustomerID"],1);
		$this->Cell(30,6,$eachResult["Name"],1);
		$this->Cell(55,6,$eachResult["Email"],1);
		$this->Cell(25,6,$eachResult["CountryCode"],1,0,'C');
		$this->Cell(20,6,$eachResult["Budget"],1);
		$this->Cell(20,6,$eachResult["Budget"],1);
		$this->Ln();
	}
}

//Better table
function ImprovedTable($header,$data)
{
	//Column widths
	$w=array(20,30,55,25,25,25);
	//Header
	for($i=0;$i<count($header);$i++)
		$this->Cell($w[$i],7,$header[$i],1,0,'C');
	$this->Ln();
	//Data

	foreach ($data as $eachResult) 
	{
		$this->Cell(20,6,$eachResult["CustomerID"],1);
		$this->Cell(30,6,$eachResult["Name"],1);
		$this->Cell(55,6,$eachResult["Email"],1);
		$this->Cell(25,6,$eachResult["CountryCode"],1,0,'C');
		$this->Cell(25,6,number_format($eachResult["Budget"],2),1,0,'R');
		$this->Cell(25,6,number_format($eachResult["Budget"],2),1,0,'R');
		$this->Ln();
	}
	//Closure line
	$this->Cell(array_sum($w),0,'','T');
}

//Colored table
function FancyTable($header,$data)
{
	//Colors, line width and bold font
	$this->SetFillColor(255,0,0);
	$this->SetTextColor(255);
	$this->SetDrawColor(128,0,0);
	$this->SetLineWidth(.3);
	$this->SetFont('','B');
	//Header
	$w=array(20,30,55,25,25,25);
	for($i=0;$i<count($header);$i++)
		$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
	$this->Ln();
	//Color and font restoration
	$this->SetFillColor(224,235,255);
	$this->SetTextColor(0);
	$this->SetFont('');
	//Data
	$fill=false;
	foreach($data as $row)
	{
		$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
		$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
		$this->Cell($w[2],6,$row[2],'LR',0,'L',$fill);
		$this->Cell($w[3],6,$row[3],'LR',0,'C',$fill);
		$this->Cell($w[4],6,number_format($row[4]),'LR',0,'R',$fill);
		$this->Cell($w[5],6,number_format($row[5]),'LR',0,'R',$fill);
		$this->Ln();
		$fill=!$fill;
	}
	$this->Cell(array_sum($w),0,'','T');
}
}

$pdf=new PDF();
//Column titles
$header=array('CustomerID','Name','Email','Country Code','Budget','Used');
//Data loading

//*** Load MySQL Data ***//
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL);
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
	$result = mysql_fetch_array($objQuery);
	array_push($resultData,$result);
}
//************************//



$pdf->SetFont('Arial','',10);

//*** Table 1 ***//
$pdf->AddPage();
$pdf->Image('logo.png',80,8,33);
$pdf->Ln(35);
$pdf->BasicTable($header,$resultData);

//*** Table 2 ***//
$pdf->AddPage();
$pdf->Image('logo.png',80,8,33);
$pdf->Ln(35);
$pdf->ImprovedTable($header,$resultData);

//*** Table 3 ***//
$pdf->AddPage();
$pdf->Image('logo.png',80,8,33);
$pdf->Ln(35);
$pdf->FancyTable($header,$resultData);

$pdf->Output("MyPDF/MyPDF.pdf","F");


//*************** Send Email ***************//

$strTo = "[email protected]";
$strSubject = "PDF Report";
$strMessage = "Download MyPDF.pdf for PDF Report";

//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));

$strHeader = "";
$strHeader .= "From: Mr.Weerachai Nukitram<[email protected]>\nReply-To: [email protected]\n";
$strHeader .= "Cc: Mr.Surachai Sirisart<[email protected]>";
$strHeader .= "Bcc: [email protected]";

$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";

$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-type: text/html; charset=windows-874\n"; // or UTF-8 //
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $strMessage."\n\n";

$strContent1 = chunk_split(base64_encode(file_get_contents("MyPDF/MyPDF.pdf")));
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"MyPDF.pdf\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"MyPDF.pdf\"\n\n";
$strHeader .= $strContent1."\n\n";


$flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "PDF Generated & Email Sending.";
}
else
{
echo "Email Can Not Send.";
}

?>
</body>
</html>

Date : 2010-06-14 18:15:52 By : webmaster
 


 

No. 7



โพสกระทู้ ( 71 )
บทความ ( 0 )



สถานะออฟไลน์


พี่คะ มัน ส่งเมลล์ไม่ได้ "Email Can Not Send."

//*************** Send Email ***************//

$strTo = "[email protected]";
$strSubject = "PDF Report";
$strMessage = "Download MyPDF.pdf for PDF Report";

//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));

$strHeader = "";
$strHeader .= "From: Mr.Weerachai Nukitram<[email protected]>\nReply-To: [email protected]\n";
$strHeader .= "Cc: Mr.Surachai Sirisart<[email protected]>";
$strHeader .= "Bcc: [email protected]";

$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";

$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-type: text/html; charset=windows-874\n"; // or UTF-8 //
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $strMessage."\n\n";

$strContent1 = chunk_split(base64_encode(file_get_contents("MyPDF/MyPDF.pdf")));
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"MyPDF.pdf\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"MyPDF.pdf\"\n\n";
$strHeader .= $strContent1."\n\n";


$flgSend = @mail($strTo,$strSubject,null,$strHeader); // @ = No Show Error //
if($flgSend)
{
echo "PDF Generated & Email Sending.";
}
else
{
echo "Email Can Not Send.";
}

?>

แต่ PDF ใช้ได้แล้วนะคะ และก็ส่งเมลล์แบบที่ไม่มีส่วน //*** Uniqid Session ***// ก็ได้ค่ะ
ไม่รู้ว่าต้องเซ็ตค่าตรงไหนอีกป๊าวคะ ขอบคุณค่ะ
Date : 2010-06-15 12:02:48 By : mostgirls
 


 

No. 8



โพสกระทู้ ( 71 )
บทความ ( 0 )



สถานะออฟไลน์


ถามอีกนิดนึงค่ะว่า ถ้าเกิดเราไม่ได้เอาค่ามาจากตารางนั้นโดยตรง แตาเราจอยมาจากหลายๆที่ทำไงคะ

และก็ include ด้วยค่ะ สามารถ include มาได้มั้ยคะ
Date : 2010-06-15 14:37:12 By : mostgirls
 


 

No. 9



โพสกระทู้ ( 71 )
บทความ ( 0 )



สถานะออฟไลน์


คือที่ถามอ่ะค่ะ ว่าจอยตาราง เวลาแสดงข้อมูลก็ไม่ได้แสดงเป็น array ด้วย จะต้องทำแบบไหนคะ
แสดงเป็นทีละบันทัดๆ และก็เวล่ส่งเมลล์ส่งให้ตาม ไอดีของลูกค้า ประมาณนี้ค่ะ

ขอบคุณลาวงหน้าคร้าาาาาาา ^^
Date : 2010-06-15 17:50:42 By : mostgirls
 


 

No. 10



โพสกระทู้ ( 1 )
บทความ ( 0 )



สถานะออฟไลน์


ผมเกิด eror ครับต้องแก้ยังงัยครับ
Warning: fopen(logo.png) [function.fopen]: failed to open stream: No such file or directory in /var/www/job/fpdf/fpdf.php on line 1746

ท่านใดพอมีวิธิการแก้ไขมั้ยครับ
Date : 2010-10-09 14:47:10 By : nut_ta
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : แปลงข้อมูล PDF แล้วแนบไฟล์ส่ง E-mail ด้วย function sendmail() ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่