Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Team

I am attaching pdf on my html content, but its not loading to open and need some help around, i experience this issue

What I have tried:

<?php
$filenameee = $_FILES['id']['name'];

 $message = "Name: ". $fname . $lname . "\r\n Email: " . $email . "\r\n Cell Number: " . $number . "\r\n Monthly Income: " . $income . "\r\n Loan Amount: " . $amount . "\r\n Town:" . $town . "\r\n id :.$filenameee.";

   $subject ="Application Form";
   $fromname ="ACI FINANCE";
   $fromemail = $email; //if u dont have an email create one on your cpanel
   $mailto = 'gcobani.mkontwana@agilelimitless.org.za'; //the email which u want to recv this email


// Define the message body
$body = '--'.$separator.$eol;
$body .= 'Content-Type: text/plain; charset="iso-8859-1"'.$eol;
$body .= 'Content-Transfer-Encoding: 8bit'.$eol.$eol;
$body .= $message.$eol;

    // Define the first attachment
$filenameee = 'public_html/PHPMailer/path/to/attachment1/id.pdf';
$file_size = filesize($filenameee);
$file_name = basename($filenameee);
$handle = @fopen($filenameee, 'rb');
$content = @fread($handle, $file_size);
@fclose($handle);
$attachment = chunk_split(base64_encode($content));
$body .= '--'.$separator.$eol;
$body .= 'Content-Type: application/pdf; name="'.$file_name.'"'.$eol;
$body .= 'Content-Transfer-Encoding: base64'.$eol;
$body .= 'Content-Disposition: attachment; filename="'.$file_name.'"'.$eol.$eol;
$body .= $attachment.$eol;
$body .= '--'.$separator.'--'.$eol;

?>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900