<?php
error_reporting(E_ALL|E_STRICT);
$r = $_REQUEST;
$string = '';
$postdata = file_get_contents('php://input');
$name = 'PDF_form_'.date('Ymd_his').'_'.rand(1000,9999).'.pdf';
$file = "/tmp/$name"; //needs to be writable
$f = fopen( $file, 'w' );
fwrite( $f, $postdata );
fclose($f);
$finfo = finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension
$info = finfo_file($finfo,$file);
finfo_close($finfo);
if ( $info !== 'application/pdf' )
{
@unlink($file);
die("Error: the file type you have submitted ($info) is not valid.");
}
$pdf = wordwrap(base64_encode($postdata),72,"\n",true);
$recipient = '[email protected]';
$cc = '[email protected]';
$sender = '[email protected]';
$subject = 'PDF Form';
$boundary = '==Multipart_Mix_x'.md5(rand(1000,9999)).'x';
$headers = "From: $sender\n";
$headers .= "Cc: $cc\n";
$headers .= "X-Mailer: NetLink IT Services\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'."\n\n";
$message = <<<__MESSAGE__
This is a multi-part message in MIME format.
--{$boundary}
Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
Application form attached. For support, please contact support @ netlink.ie.
--{$boundary}
Content-Type: application/pdf;
name="{$name}"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="{$name}"
{$pdf}
--{$boundary}--
__MESSAGE__;
mail($recipient,$subject,$message,$headers);
header('Content-type: application/vnd.fdf');
?>
%FDF-1.2
%âãÏÓ
1 0 obj
<<
/FDF
<<
/Status(Thank you. Your details have been submitted and someone will get in touch with you regarding your application.)
>>
>>
endobj
trailer
<</Root 1 0 R>>
%%EOF
|