最新消息:

PHP类第6款:download.class.php下载指定格式文件的类

PHP模块 杨红伟 4982浏览 0评论

一、类介绍

当我们下载文件的时候,可能有好多种格式,这样我们下载文件的时候,就会有选择的方式。这款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();   
}  



Warning: Use of undefined constant PRC - assumed 'PRC' (this will throw an Error in a future version of PHP) in /www/wwwroot/www.ijquery.cn/wp-content/themes/d8-3.0/comments.php on line 17
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址