- 浏览: 13631234 次
- 性别:
- 来自: 洛杉矶
文章分类
- 全部博客 (1994)
- Php / Pear / Mysql / Node.js (378)
- Javascript /Jquery / Bootstrap / Web (435)
- Phone / IOS / Objective-C / Swift (137)
- Ubuntu / Mac / Github / Aptana / Nginx / Shell / Linux (335)
- Perl / Koha / Ruby / Markdown (8)
- Java / Jsp (12)
- Python 2 / Wxpython (25)
- Codeigniter / CakePHP (32)
- Div / Css / XML / HTML5 (179)
- WP / Joomla! / Magento / Shopify / Drupal / Moodle / Zimbra (275)
- Apache / VPN / Software (31)
- AS3.0/2.0 / Flex / Flash (45)
- Smarty (6)
- SEO (24)
- Google / Facebook / Pinterest / SNS (80)
- Tools (22)
最新评论
-
1455975567:
xuezhongyu01 写道wocan23 写道我想问下那个 ...
Mysql: LBS实现查找附近的人 (两经纬度之间的距离) -
xuezhongyu01:
wocan23 写道我想问下那个111.1是怎么得来的我也看不 ...
Mysql: LBS实现查找附近的人 (两经纬度之间的距离) -
18335864773:
试试 pageoffice 在线打开 PDF 文件吧. pag ...
jquery在线预览PDF文件,打开PDF文件 -
青春依旧:
opacity: 0.5; 个人喜欢这种方式!关于其他css特 ...
css透明度的设置 (兼容所有浏览器) -
July01:
推荐用StratoIO打印控件,浏览器和系统的兼容性都很好,而 ...
搞定网页打印自动分页问题
PHP 文件下载类
<? //==================================================== // FileName:download.class.php // Summary: 文件下载类 // // 使用范例: // $download = new download('php,exe,html',false); // if(!$download->downloadfile($filename)) // { // echo $download->geterrormsg(); // } //==================================================== class download { var $debug=true; var $errormsg=''; var $Filter=array(); var $filename=''; var $mineType='text/plain'; var $xlq_filetype=array(); function __construct($fileFilter='',$isdebug=true) { $this->setFilter($fileFilter); $this->setdebug($isdebug); $this->setfiletype(); } function setFilter($fileFilter) { if(empty($fileFilter)) return ; $this->Filter=explode(',',strtolower($fileFilter)); } function setdebug($debug) { $this->debug=$debug; } function setfilename($filename) { $this->filename=$filename; } function downloadfile($filename) { $this->setfilename($filename); if($this->filecheck()) { $fn = array_pop( explode( '/', strtr( $this->filename, '\\', '/' ) ) ); header( "Pragma: public" ); header( "Expires: 0" ); // set expiration time header( "Cache-Component: must-revalidate, post-check=0, pre-check=0" ); header( "Content-type:".$this->mineType ); header( "Content-Length: " . filesize( $this->filename ) ); header( "Content-Disposition: attachment; filename=\"$fn\"" ); header( 'Content-Transfer-Encoding: binary' ); readfile( $this->filename ); return true; } else { return false; } } function geterrormsg() { return $this->errormsg; } function filecheck() { $filename=$this->filename; if(file_exists($filename)) { $filetype=strtolower(array_pop(explode('.',$filename))); if(in_array($filetype,$this->Filter)) { $this->errormsg.=$filename.'不允许下载!'; if($this->debug) exit($filename.'不允许下载!') ; return false; }else { if ( function_exists( "mime_content_type" ) ) { $this->mineType = mime_content_type( $filename ); } if(empty($this->mineType)) { if( isset($this->xlq_filetype[$filetype]) ) $this->mineType = $this->xlq_filetype[$filetype]; } if(!empty($this->mineType)) return true; else { $this->errormsg.='获取'.$filename.'文件类型时候发生错误,或者不存在预定文件类型内'; if($this->debug) exit('获取文件类型出错'); return false; } } }else { $this->errormsg.=$filename.'不存在!'; if($this->debug) exit($filename.'不存在!') ; return false; } } function setfiletype() { $this->xlq_filetype['chm']='application/octet-stream'; $this->xlq_filetype['ppt']='application/vnd.ms-powerpoint'; $this->xlq_filetype['xls']='application/vnd.ms-excel'; $this->xlq_filetype['doc']='application/msword'; $this->xlq_filetype['exe']='application/octet-stream'; $this->xlq_filetype['rar']='application/octet-stream'; $this->xlq_filetype['js']="javascript/js"; $this->xlq_filetype['css']="text/css"; $this->xlq_filetype['hqx']="application/mac-binhex40"; $this->xlq_filetype['bin']="application/octet-stream"; $this->xlq_filetype['oda']="application/oda"; $this->xlq_filetype['pdf']="application/pdf"; $this->xlq_filetype['ai']="application/postsrcipt"; $this->xlq_filetype['eps']="application/postsrcipt"; $this->xlq_filetype['es']="application/postsrcipt"; $this->xlq_filetype['rtf']="application/rtf"; $this->xlq_filetype['mif']="application/x-mif"; $this->xlq_filetype['csh']="application/x-csh"; $this->xlq_filetype['dvi']="application/x-dvi"; $this->xlq_filetype['hdf']="application/x-hdf"; $this->xlq_filetype['nc']="application/x-netcdf"; $this->xlq_filetype['cdf']="application/x-netcdf"; $this->xlq_filetype['latex']="application/x-latex"; $this->xlq_filetype['ts']="application/x-troll-ts"; $this->xlq_filetype['src']="application/x-wais-source"; $this->xlq_filetype['zip']="application/zip"; $this->xlq_filetype['bcpio']="application/x-bcpio"; $this->xlq_filetype['cpio']="application/x-cpio"; $this->xlq_filetype['gtar']="application/x-gtar"; $this->xlq_filetype['shar']="application/x-shar"; $this->xlq_filetype['sv4cpio']="application/x-sv4cpio"; $this->xlq_filetype['sv4crc']="application/x-sv4crc"; $this->xlq_filetype['tar']="application/x-tar"; $this->xlq_filetype['ustar']="application/x-ustar"; $this->xlq_filetype['man']="application/x-troff-man"; $this->xlq_filetype['sh']="application/x-sh"; $this->xlq_filetype['tcl']="application/x-tcl"; $this->xlq_filetype['tex']="application/x-tex"; $this->xlq_filetype['texi']="application/x-texinfo"; $this->xlq_filetype['texinfo']="application/x-texinfo"; $this->xlq_filetype['t']="application/x-troff"; $this->xlq_filetype['tr']="application/x-troff"; $this->xlq_filetype['roff']="application/x-troff"; $this->xlq_filetype['shar']="application/x-shar"; $this->xlq_filetype['me']="application/x-troll-me"; $this->xlq_filetype['ts']="application/x-troll-ts"; $this->xlq_filetype['gif']="image/gif"; $this->xlq_filetype['jpeg']="image/pjpeg"; $this->xlq_filetype['jpg']="image/pjpeg"; $this->xlq_filetype['jpe']="image/pjpeg"; $this->xlq_filetype['ras']="image/x-cmu-raster"; $this->xlq_filetype['pbm']="image/x-portable-bitmap"; $this->xlq_filetype['ppm']="image/x-portable-pixmap"; $this->xlq_filetype['xbm']="image/x-xbitmap"; $this->xlq_filetype['xwd']="image/x-xwindowdump"; $this->xlq_filetype['ief']="image/ief"; $this->xlq_filetype['tif']="image/tiff"; $this->xlq_filetype['tiff']="image/tiff"; $this->xlq_filetype['pnm']="image/x-portable-anymap"; $this->xlq_filetype['pgm']="image/x-portable-graymap"; $this->xlq_filetype['rgb']="image/x-rgb"; $this->xlq_filetype['xpm']="image/x-xpixmap"; $this->xlq_filetype['txt']="text/plain"; $this->xlq_filetype['c']="text/plain"; $this->xlq_filetype['cc']="text/plain"; $this->xlq_filetype['h']="text/plain"; $this->xlq_filetype['html']="text/html"; $this->xlq_filetype['htm']="text/html"; $this->xlq_filetype['htl']="text/html"; $this->xlq_filetype['rtx']="text/richtext"; $this->xlq_filetype['etx']="text/x-setext"; $this->xlq_filetype['tsv']="text/tab-separated-values"; $this->xlq_filetype['mpeg']="video/mpeg"; $this->xlq_filetype['mpg']="video/mpeg"; $this->xlq_filetype['mpe']="video/mpeg"; $this->xlq_filetype['avi']="video/x-msvideo"; $this->xlq_filetype['qt']="video/quicktime"; $this->xlq_filetype['mov']="video/quicktime"; $this->xlq_filetype['moov']="video/quicktime"; $this->xlq_filetype['movie']="video/x-sgi-movie"; $this->xlq_filetype['au']="audio/basic"; $this->xlq_filetype['snd']="audio/basic"; $this->xlq_filetype['wav']="audio/x-wav"; $this->xlq_filetype['aif']="audio/x-aiff"; $this->xlq_filetype['aiff']="audio/x-aiff"; $this->xlq_filetype['aifc']="audio/x-aiff"; $this->xlq_filetype['swf']="application/x-shockwave-flash"; } }
PHP header发送各种类型文件下载
发表评论
-
PHP: 在类(class)中加载动态函数, 变量函数或半变量函数 variable function/method
2016-09-03 07:54 7092最终实例在下方 以前 ... -
MySQL入门 (七) : 储存引擎与资料型态
2016-09-03 07:49 45001 表格与储存引擎 表格(table)是资料库中用来储存 ... -
MySQL入门 (六) : 字元集与资料库
2016-09-03 07:47 44981 Character Set与Collation 任何 ... -
MySQL入门 (五) : CRUD 与资料维护
2016-09-03 07:46 54131 取得表格资讯 1.1 DESCRIBE指令 「 ... -
MySQL入门 (四) : JOIN 与UNION 查询
2016-09-03 07:42 44351 使用多个表格 在「world」资料库的「countr ... -
PHP: 关键字global 和 超全局变量$GLOBALS的用法、解释、区别
2016-08-31 12:07 4977$GLOBALS 是一个关联数组,每一个变量为一个 ... -
MySQL入门 (三) : 运算式与函式
2016-08-31 12:01 4323运算式(expressions)已经 ... -
MySQL入门 (二) : SELECT 基础查询
2016-08-31 11:56 46291 查询资料前的基本概念 1.1 表格、纪录 ... -
MySQL入门 (一) : 资料库概论与MySQL的安装
2016-08-31 11:51 43911. 储存与管理资料 储存与管理资料一直是资讯应用上最基本 ... -
MySQL入门 (九) : 子查询 Subquery
2016-08-30 02:26 43931 一个叙述中的查询叙述 子查询(subquery)是一 ... -
PHP: 用readonly取代disabled来获取input值 submit a disabled input in a form could not ge
2016-08-30 02:21 2645The form is like below; <f ... -
PHP7革新与性能优化
2016-08-30 02:20 2093有幸参与2015年的PHP技 ... -
Mysql: 图解 inner join、left join、right join、full outer join、union、union all的区别
2016-08-18 06:03 3065对于SQL的Join,在学习起来可能是比较乱的。我们知道, ... -
Comet 反Ajax: 基于jQuery与PHP实现Ajax长轮询(LongPoll)
2016-08-18 06:00 1325传统的AJAX轮询方式,客服端以用户定义的时间间隔去服务器上 ... -
PHP:ServerPush (Comet推送) 技术的探讨
2016-08-18 05:58 986PHP中Push(推送)技术的探讨 [http://vi ... -
PHP: 手把手编写自己的 MVC 框架实例教程
2016-08-16 05:33 17591 什么是MVC MVC模式(Model-View-Con ... -
PHP5: mysqli 插入, 查询, 更新和删除 Insert Update Delete Using mysqli (CRUD)
2016-07-29 12:55 1695原文: PHP5: mysqli 插入, 查询, 更新 ... -
MongoDB 教程索引 (附有视频)
2016-07-27 10:54 690MongoDB 教程索引 MongoDB 教程一: ... -
Node.js 模块之Nimble流程控制
2016-07-18 12:59 1036NodeJS异步的特性有时候 ... -
Node.js web应用模块之Supervisor
2016-07-18 12:56 2280在开发或调试Node.js应 ...
相关推荐
php 文件下载类
php文件下载类,文件下载类,php下载类
PHP文件下载类,可以直接调用,操作文件下载
php文件下载类,注释的非常清楚,有下载实例
// $download=new download('php,exe,html',false); // if(!$download->downloadfile($filename)) // { // echo $download->geterrormsg(); // }
PHP文件下载类,很好很实用哦!!!!推荐下载.............
PHP文件上传类,自定义配置,包括单文件和多文件上传(检测文件大小,文件格式,文件重命名,错误返回,全部封装在一个类中)
一个用php写的文件下载类,可支持限速,断点续传及普通下载方式,有示例程序,使用很方便
功能:支持断点续传的下载,能计算传输率,能控制传输率
这里为各位提供一款远程文件下载代码,我们可以把远程的文件用php下载到本地指定的目录,下面就是一款下载远程服务器文件代码类,需要的朋友可以自己下载参考。
使用curl的批处理方法,开启多进程,实现批量下载文件。批量下载文件一般使用循环的方式,逐一执行下载。但在带宽与服务器性能允许的情况下,使用多进程进行...本类利用curl的多进程请求方法,实现多进程同时下载文件。
PHP文件下载类,里面封装了PHP写下载功能时所需要的常用类,非常好用,人品保证,欢迎使用
代码审计-PHP 项目类 RCE 及文件包含下载删#漏洞关键字:select insert update mysql_query mysqli 等文件上传:$_
php文件操作类
分享一个从FTP获取自动下载文件的php类,连接ftp服务器登陆获取ftp路径,文件名,进入指定路径,或者创建新的目录,下载指定的FTP文件到指定的本地文件。
PHP文件下载类 PHP无限分类[左右值]算法 PHP显示日期、周几、农历初几、什么节日函数 PHP格式化数据,防止注入函数 PHP模拟登陆 PHP生成唯一标识符函数 PHP生成曲线图函数 PHP生成条形码 PHP统计字符串里...
分享一个php中一个很好用的文件上传类,用于文件初始化,获取当前类的所有的属性,定义不同的错误级别,为成员属性赋值的函数。
介绍一个php下载远程文件到本地存储的函数类,需要的朋友可以下载学习参考。
PHP FTP类,实现对文件的上传下载 移动 删除 重命名 文件夹的创建 删除
实用的php文件操作类