RON_ron Posted October 19, 2009 Share Posted October 19, 2009 I'm not a PHP guy. Please explain what doses this piece of code mean. I'm trying to figureout how to send an attachment by generating a PDF in PHP. $pdfdoc = $pdf->Output("", "S"); // what's this? $attachment = chunk_split(base64_encode($pdfdoc)); //what's this? Quote Link to comment https://forums.phpfreaks.com/topic/178190-this-code/ Share on other sites More sharing options...
trq Posted October 19, 2009 Share Posted October 19, 2009 Without knowing what the $pdf object is we really can't help much (its a 3rd party library of some sort). Quote Link to comment https://forums.phpfreaks.com/topic/178190-this-code/#findComment-939501 Share on other sites More sharing options...
RON_ron Posted October 19, 2009 Author Share Posted October 19, 2009 Thanks for your reply! How do I write the code to a server side script get an image? Quote Link to comment https://forums.phpfreaks.com/topic/178190-this-code/#findComment-939505 Share on other sites More sharing options...
Gayner Posted October 19, 2009 Share Posted October 19, 2009 Thanks for your reply! How do I write the code to a server side script get an image? LOL Bro u need to show us ur whole code. Quote Link to comment https://forums.phpfreaks.com/topic/178190-this-code/#findComment-939510 Share on other sites More sharing options...
RON_ron Posted October 19, 2009 Author Share Posted October 19, 2009 <?php require("/fpd/fpdf.php"); $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont("Arial","B",14); $pdf->Cell(40,10, "this is a <strong class="highlight">pdf</strong> example"); $to = "[email protected]"; $from = "BBQ"; $subject = "<strong class="highlight">send</strong> <strong class="highlight">email</strong> with <strong class="highlight">pdf</strong> attachment"; $message = "<p>Please see the attachment.</p>"; $separator = md5(time()); $eol = PHP_EOL; $filename = "example.pdf"; $pdfdoc = $pdf->Output("", "S"); $attachment = chunk_split(base64_encode($pdfdoc)); $headers = "From: ".$from.$eol; $headers .= "MIME-Version: 1.0".$eol; $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol; $headers .= "Content-Transfer-Encoding: 7bit".$eol; $headers .= "This is a MIME encoded message.".$eol.$eol; $headers .= "--".$separator.$eol; $headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol; $headers .= "Content-Transfer-Encoding: base64".$eol; $headers .= "Content-Disposition: attachment".$eol.$eol; $headers .= $attachment.$eol.$eol; $headers .= "--".$separator."--"; mail($to, $subject, "", $headers); mail($to, $subject, "", $headers); ?> Quote Link to comment https://forums.phpfreaks.com/topic/178190-this-code/#findComment-939523 Share on other sites More sharing options...
Prismatic Posted October 19, 2009 Share Posted October 19, 2009 As per fpdf.org Output string Output([string name, string dest]) Description Send the document to a given destination: browser, file or string. In the case of browser, the plug-in may be used (if present) or a download ("Save as" dialog box) may be forced. The method first calls Close() if necessary to terminate the document. Parameters name The name of the file. If not specified, the document will be sent to the browser (destination I) with the name doc.pdf. dest Destination where to send the document. It can take one of the following values: I: send the file inline to the browser. The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF. D: send to the browser and force a file download with the name given by name. F: save to a local file with the name given by name (may include a path). S: return the document as a string. name is ignored. Quote Link to comment https://forums.phpfreaks.com/topic/178190-this-code/#findComment-939557 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.