All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
VS2005开发中Timer控件失效的解决方法_[Asp.Net教程]
限量版广告,1个IP一天只弹一次的AD代码_JavaScript技术_编程技术
Asp.Net生成静态页面实例代码_[Asp.Net教程]
学习网页Web标准:DOCTYPE(文档类型)基础知识_[Html教程]
asp.net2.0实现主从数据表的简单方法_[Asp.Net教程]
浅议ASP.NET中Session的状态保持方式_[Asp.Net教程]
asp.net代码实现MSSQL数据库创建及操作_[Asp.Net教程]
ASP.NET,2.0角色及成员管理_.net资料_编程技术
关于在php.ini中添加extension=php_mysqli.dll指令的说明_php资料_编程技术
用PHP实现文件上传_php资料_编程技术
Reading number is top 10 pictures
NeedWallpaper6
西游四格漫画(二)
西游日记1
30 beautiful school beauty1
XuYing poker perspective garment debut
Sora aoi mirror memorial classics4
Summer is most suitable for young people to travel in China3
Wear bikinis cock
青春清纯美女大集合4
美女和狗狗1
Download software ranking
White deer villiage
Tram sex maniac 2 (H) rar bag7
美女写真3
Kung.Fu.Panda.2
Boxer vs Yellow5
美女写真1
Sora aoi - one of more PK
Boxer's Top ten classic battle7
Jinling thirteen stock
Sora aoi, the nurse, uniform ,nursing assistant
aaa published in(发表于) 2013/12/24 5:49:34 Edit(编辑)
PHP实例教程:PHP实现文件安全下载的程序_php资料_编程技术

PHP实例教程:PHP实现文件安全下载的程序_php资料_编程技术

PHP实例教程:PHP实现文件安全下载的程序_php资料_编程技术-你的首页-uuhomepage.com

  PHP实现文件安全下载

  程序如下:


  $file_name = "info_check.exe";

  $file_dir = "/public/www/download/";

  if (!file_exists($file_dir . $file_name)) { //检查文件是否存在

  echo "文件找不到";

  exit;

  } else {

  $file = fopen($file_dir . $file_name,"r"); //打开文件

  //输入文件标签

  Header("Content-type: application/octet-stream");

  Header("Accept-Ranges: bytes");

  Header("Accept-Length: ".filesize($file_dir . $file_name));

  Header("Content-Disposition: attachment; filename=" . $file_name);

  //输出文件内容

  echo fread($file,filesize($file_dir . $file_name));

  fclose($file);

  exit;}

  而如果文件路径是"http"或者"ftp"网址的话,则源代码会有少许改变,程序如下:

  $file_name = "info_check.exe";

  $file_dir = "www.webjx.com/";

  $file = @ fopen($file_dir . $file_name,"r");

  if (!$file) {

  echo "文件找不到";

  } else {

  Header("Content-type: application/octet-stream");

  Header("Content-Disposition: attachment; filename=" . $file_name);

  while (!feof ($file)) {

  echo fread($file,50000);

  }

  fclose ($file);

  }

  这样就可以用PHP直接输出文件了





添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.