diff --git a/application/default/controllers/ReviewController.php b/application/default/controllers/ReviewController.php index 7e2fdedf..80f6714c 100644 --- a/application/default/controllers/ReviewController.php +++ b/application/default/controllers/ReviewController.php @@ -313,7 +313,7 @@ class ReviewController extends Zend_Controller_Action $sth = $this->db->prepare($sql); if($sth->execute()) { - if($_POST['atts']) + if(isset($_POST['atts'])) { $review = $sth->fetch(PDO::FETCH_ASSOC); $reviewid=$review['id']; @@ -415,6 +415,58 @@ class ReviewController extends Zend_Controller_Action exit(); }// ajax 评审附件列表 + + function downattAction(){ + + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + $id = $this->_request->getParam('id'); + + $sql = "select * from attachments where id='$id'"; + + $re = $this->db->query($sql); + + $row = $re->fetch(); + + $file = new files(); + + $fullPath = $this->view->config->upload.$row['filename']; + + $fsize = filesize($fullPath); + $path_parts = pathinfo($fullPath); + $ext = strtolower($path_parts["extension"]); + + switch ($ext) { + case "pdf": $ctype="application/pdf"; break; + case "exe": $ctype="application/octet-stream"; break; + case "zip": $ctype="application/zip"; break; + case "doc": $ctype="application/msword"; break; + case "xls": $ctype="application/vnd.ms-excel"; break; + case "ppt": $ctype="application/vnd.ms-powerpoint"; break; + case "gif": $ctype="image/gif"; break; + case "png": $ctype="image/png"; break; + case "jpeg": + case "jpg": $ctype="image/jpg"; break; + default: $ctype="application/force-download"; + } + + $content=file_get_contents($fullPath); + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + $this->getResponse()->setHeader('Content-Type', 'application/octet-stream') + ->setHeader('Content-Disposition','attachment; filename="'.basename($fullPath).'"') + ->setHeader('Content-Length', $fsize) + ->setHeader('Content-Type','application/force-download') + ->setHeader('Content-Type','application/download') + ->setHeader('Content-Type',$ctype) + ->setHeader('Content-Description','File Transfer') + ->setHeader('Content-Transfer-Encoding','binary') + ->setHeader('Expires',0) + ->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0') + ->setHeader('Pragma','public') + ->setBody($content); + }// downattAction 下载附件 } diff --git a/application/default/views/scripts/review/review.phtml b/application/default/views/scripts/review/review.phtml index 767d53ee..42827c3b 100755 --- a/application/default/views/scripts/review/review.phtml +++ b/application/default/views/scripts/review/review.phtml @@ -207,6 +207,8 @@ $(document).ready(function() { 'script' : '/service/upload', 'cancelImg' : '/static/js/uploadify/cancel.png', 'folder' : '/uploads', + 'sizeLimit' : 10485760, + 'queueSizeLimit' : 10, 'multi' : true, 'auto' : false, 'displayData' : 'speed',