diff --git a/application/admin/controllers/DataController.php b/application/admin/controllers/DataController.php
index b9eb09a5..4c6c3213 100755
--- a/application/admin/controllers/DataController.php
+++ b/application/admin/controllers/DataController.php
@@ -747,6 +747,7 @@ class Admin_DataController extends Zend_Controller_Action
if(empty($msg['error']))
{
$filename = $msg['db_path'];
+ $filesize = $msg['file_size'];
$filedesc = $this->_request->getParam('filedesc');
$filetype = $this->_request->getParam('dir');
@@ -755,7 +756,7 @@ class Admin_DataController extends Zend_Controller_Action
{
$user = $auth->getIdentity();
$userid = $user->id;
- $sql = "insert into attachments (filename,filetype,filedesc,userid) values ('$filename','$filetype','$filedesc','$userid')";
+ $sql = "insert into attachments (filename,filetype,filedesc,userid,filesize) values ('$filename','$filetype','$filedesc','$userid','$filesize')";
if($this->db->exec($sql)>0)
{
$this->messenger->addMessage('附件上传成功!');
@@ -880,9 +881,64 @@ class Admin_DataController extends Zend_Controller_Action
}
}//我的附件列表
+ else if ($down>0)
+ {
+
+ $sql = "select * from attachments where id='$down'";
+
+ $re = $this->db->query($sql);
+
+ $row = $re->fetch();
+
+ $file = new files();
+
+ $fullPath = Zend_Registry::get('upload').$row['filename'];
+
+
+ // Parse Info / Get Extension
+ $fsize = filesize($fullPath);
+ $path_parts = pathinfo($fullPath);
+ $ext = strtolower($path_parts["extension"]);
+
+ // Determine Content Type
+ 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);
+
+ $sql = "update attachments set downtimes=downtimes+1 where id='$down'";
+ $this->db->exec($sql);
+
+ }//附件下载
+
else
{
- $sql="select * from attachments";
+ $sql="select * from attachments order by id desc";
$re= $this->db->query($sql);
$rows = $re->fetchAll();
diff --git a/application/admin/views/scripts/data/attachments.phtml b/application/admin/views/scripts/data/attachments.phtml
index 508dd4ba..853c4c43 100644
--- a/application/admin/views/scripts/data/attachments.phtml
+++ b/application/admin/views/scripts/data/attachments.phtml
@@ -42,6 +42,8 @@
@@ -56,11 +58,13 @@
if($item['filetype']=='file') echo '文件' ;
if($item['filetype']=='media') echo '多媒体' ;
?>
+ 描述
类型
+ 大小
+ 下载次数
上传时间
操作