<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta forua="true" http-equiv="Cache-Control" content="max-age=0" /></head>
<card title="php实现文件下载实例代码 application/octet-stream attachment;filename=" id="card1">
<p> 游客</p><p>
标题:php实现文件下载实例代码 application/octet-stream attachment;filename=<br/>
正文:<br/>
举一个案例：代码如下:&amp;lt;?php<br/>class Downfile {<br/><br/>    function downserver($file_name){<br/>        $file_path = &quot;./img/&quot;.$file_name;<br/>        //转码，文件名转为gb2312解决中文乱码<br/>        $file_name = iconv(&quot;utf-8&quot;,&quot;gb2312&quot;,$file_name);<br/>        $file_path = iconv(&quot;utf-8&quot;,&quot;gb2312&quot;,$file_path);<br/>        $fp = fopen($file_path,&quot;r&quot;) or exit(&quot;文件不存在&quot;);<br/>        //定义变量空着每次下载的大小 @camnpr<br/>        $buffer = 1024;<br/>        //得到文件的大小<br/>        $file_size = filesize($file_path);<br/>        //header(&quot;Content-type:text/html;charset=gb2312&quot;);<br/>        //会写用到的四条http协议信息<br/>        header(&quot;Content-type:application/octet-stream&quot;);<br/>        header(&quot;Accept-Ranges:bytes&quot;);//可以忽略<br/>        header(&quot;Content-Length: &quot;.$file_size);//原文这里是Accept-Length经查阅http协议无此项<br/>        header(&quot;Content-Disposition:attachment;filename=&quot;.$file_name);<br/>        //字节技术器，纪录当前现在字节数 @郑州网建<br/>        $count = 0;<br/>        while(!feof($fp) &amp;amp;&amp;amp; $file_size-$count&amp;gt;0){<br/>            //<br/><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1743&amp;Page=1">[&lt;&lt;]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1743&amp;Page=1">[[1]]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1743&amp;Page=2">[2]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1743&amp;Page=2">[&gt;&gt;]</a><br/>
<br/>
<a href="wap.asp?act=Com&amp;id=1743">查看评论(0)</a><br/>
<a href="wap.asp?act=AddCom&amp;inpId=1743">发表评论</a><br/><br/>

<br/>

<br/>
<a href="http://camnpr.com/wap.asp">首页</a>
</p>
</card>
</wml>