一、类介绍
当我们下载文件的时候,可能有好多种格式,这样我们下载文件的时候,就会有选择的方式。这款PHP文件下载类,就可以解决这一问题。
二、类的使用方法
1、允许下载的文件格式,下边的例子是允许下载的是txt格式
示例: http://www.ijquery.cn/phpclass/download/demo1.php
require_once "class/download.class.php"; $download=new download('php,exe,html',true); //不下载指定的格式 $filename="hello.txt"; //允许下载的txt if(!$download->downloadfile($filename)) { echo $download->geterrormsg(); }
返回的结果是:
2、不允许下载的文件格式,下边的例子是不允许下载的是html格式
示例: http://www.ijquery.cn/phpclass/download/demo2.php
require_once "class/download.class.php"; $download=new download('php,exe,html',true); $filename="hello.html"; //不允许下载 html if(!$download->downloadfile($filename)) { echo $download->geterrormsg(); }