I've made some changes to the code, now the file is shown as it should (in the attachment), but the size is still incorrect and I still have an error message:
Q298169.pdf can not be opened because the filetype is not supported or the file is damaged (because its send as an attachment or it is wrongly decoded).
The code I use: (to attach an attachment)
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
list($tmp_id,$tmp_name) = explode('#',$ticket['attachments']);
/* Get attachment info */
$sql = "SELECT * FROM `".$hesk_settings['db_pfix']."attachments` WHERE `att_id`=$tmp_id LIMIT 1";
$result = hesk_dbQuery($sql);
if (hesk_dbNumRows($result) != 1)
$file = hesk_dbFetchAssoc($result);
$attachment = chunk_split(base64_encode(file_get_contents($hesk_settings['server_path'].'/attachments/'.$file[saved_name])));
$ticket['attachments'] = $file['real_name'];
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: application/pdf; name="<?php echo $ticket['attachments']; ?>"
<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--
I can display the right size but this require me to remove the following 2 parts from the code:
Then only the error remains.
I dont know why this error is keep coming up, please help.