修改了文件上传类,增加了评审附件的分类
This commit is contained in:
parent
e350283132
commit
91f62a2053
|
@ -26,6 +26,7 @@ class files{
|
||||||
'flash' => array('swf', 'flv'),
|
'flash' => array('swf', 'flv'),
|
||||||
'media' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'),
|
'media' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'),
|
||||||
'file' => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'htm', 'html', 'txt', 'zip', 'rar', 'gz', 'bz2'),
|
'file' => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'htm', 'html', 'txt', 'zip', 'rar', 'gz', 'bz2'),
|
||||||
|
'reviewatt'=>array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'htm', 'html', 'txt', 'zip', 'rar', 'gz', 'bz2','gif', 'jpg', 'jpeg', 'png', 'bmp')
|
||||||
);
|
);
|
||||||
//最大文件大小
|
//最大文件大小
|
||||||
$max_size = 1000000;
|
$max_size = 1000000;
|
||||||
|
@ -136,6 +137,73 @@ class files{
|
||||||
}//目录正确性
|
}//目录正确性
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
}
|
}//文件上传
|
||||||
//文件上传
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* downloadFile
|
||||||
|
*
|
||||||
|
* 文件下载
|
||||||
|
*
|
||||||
|
* @param String $fullPath e.g. Zend_Registry::get('upload').$fileurl
|
||||||
|
*
|
||||||
|
* return file
|
||||||
|
*/
|
||||||
|
static function downloadFile( $fullPath ){
|
||||||
|
|
||||||
|
//判断是否已经输出头部
|
||||||
|
if( headers_sent() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
|
||||||
|
// Required for some browsers
|
||||||
|
@apache_setenv('no-gzip', 1);
|
||||||
|
@ini_set('zlib.output_compression', 0);
|
||||||
|
|
||||||
|
// File Exists?
|
||||||
|
if( file_exists($fullPath) ){
|
||||||
|
|
||||||
|
// 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";
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Content-Description: File Transfer');
|
||||||
|
header("Cache-Control: private",false);
|
||||||
|
header("Content-Type: $ctype");
|
||||||
|
header("Content-Disposition: attachment; filename=\"".basename($fullPath)."\";" );
|
||||||
|
header("Content-Transfer-Encoding: binary\n");
|
||||||
|
header("Expires: 0");
|
||||||
|
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||||
|
header("Pragma: public");
|
||||||
|
header("Content-Length: ".$fsize);
|
||||||
|
ob_clean();
|
||||||
|
flush();
|
||||||
|
if(readfile($fullPath))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
{return false;}
|
||||||
|
}
|
||||||
|
} //文件下载
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue