cmc-sales/controllers/email_attachments_controller.php
2010-05-11 15:02:11 +10:00

34 lines
897 B
PHP
Executable file

<?php
class EmailAttachmentsController extends AppController {
var $name = 'EmailAttachments';
var $helpers = array('Html', 'Form');
function download($id) {
$file = $this->EmailAttachment->findById($id);
if(file_exists($file['EmailAttachment']['filename'])) {
Configure::write('debug', 0);
header('Content-type: ' . $file['EmailAttachment']['type']);
header('Content-length: ' . $file['EmailAttachment']['size']);
header('Content-Disposition: attachment; filename='.$file['EmailAttachment']['name']);
// ob_clean();
// flush();
readfile($file['EmailAttachment']['filename']);
// echo $file['EmailAttachment']['filename']
exit();
}
else {
echo "ERROR!! : File Not Found";
echo $file['EmailAttachment']['filename'];
}
}
}