2009-02-09 14:25:49 -08:00
|
|
|
<?php
|
|
|
|
|
class EmailAttachmentsController extends AppController {
|
|
|
|
|
|
2010-04-26 23:49:20 -07:00
|
|
|
var $name = 'EmailAttachments';
|
|
|
|
|
var $helpers = array('Html', 'Form');
|
2009-02-09 14:25:49 -08:00
|
|
|
|
|
|
|
|
|
2010-04-26 23:49:20 -07:00
|
|
|
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']));
|
2010-04-27 00:05:36 -07:00
|
|
|
header('Content-Transfer-Encoding: binary');
|
|
|
|
|
header('Expires: 0');
|
|
|
|
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
2010-04-26 23:49:20 -07:00
|
|
|
ob_clean();
|
2010-04-27 00:05:36 -07:00
|
|
|
flush();
|
2010-04-26 23:49:20 -07:00
|
|
|
readfile($file['EmailAttachment']['filename']);
|
2010-04-27 00:05:36 -07:00
|
|
|
// echo $file['EmailAttachment']['filename']
|
2010-04-26 23:49:20 -07:00
|
|
|
exit();
|
|
|
|
|
}
|
2009-02-09 14:25:49 -08:00
|
|
|
|
|
|
|
|
}
|