cmc-sales/controllers/email_attachments_controller.php

34 lines
897 B
PHP
Raw Normal View History

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) {
2010-05-10 22:02:11 -07:00
2010-04-26 23:49:20 -07:00
$file = $this->EmailAttachment->findById($id);
2010-05-10 22:02:11 -07:00
if(file_exists($file['EmailAttachment']['filename'])) {
Configure::write('debug', 0);
2010-04-26 23:49:20 -07:00
header('Content-type: ' . $file['EmailAttachment']['type']);
header('Content-length: ' . $file['EmailAttachment']['size']);
2010-04-27 00:14:47 -07:00
header('Content-Disposition: attachment; filename='.$file['EmailAttachment']['name']);
// ob_clean();
// flush();
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();
2010-05-10 22:02:11 -07:00
}
else {
echo "ERROR!! : File Not Found";
echo $file['EmailAttachment']['filename'];
}
2010-04-26 23:49:20 -07:00
}
2009-02-09 14:25:49 -08:00
}