cmc-sales/controllers/email_attachments_controller.php
2010-04-27 17:05:36 +10:00

25 lines
843 B
PHP
Executable file

<?php
class EmailAttachmentsController extends AppController {
var $name = 'EmailAttachments';
var $helpers = array('Html', 'Form');
function download($id) {
Configure::write('debug', 0);
$file = $this->EmailAttachment->findById($id);
header('Content-type: ' . $file['EmailAttachment']['type']);
header('Content-length: ' . $file['EmailAttachment']['size']);
header('Content-Disposition: attachment; filename='.basename($file['EmailAttachment']['name']));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
ob_clean();
flush();
readfile($file['EmailAttachment']['filename']);
// echo $file['EmailAttachment']['filename']
exit();
}
}