<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_45056"> <div class="blockcode"> <div id="code_exN"><ol> <li> <li><?php<li>/**<li>* php文件下载示例<li>* by bbs.it-home.org<li>*/<li>ob_start();<li>$ua = $_SERVER["HTTP_USER_AGENT"];<li>$filename ="脚本学堂_文件下载.doc";//注意转码<li>$encoded_filename = urlencode($filename);<li>//兼容各种浏览器<li>$encoded_filename = str_replace(" ", " ", $encoded_filename);<li>header('Content-Type: application/octet-stream');<li>if (preg_match("/MSIE/", $ua)) <li>{ <li>header('Content-Disposition: attachment; filename="'.urldecode($encoded_filename).'"');<li>} <li>else if (preg_match("/Firefox/", $ua)) <li>{<li>header('Content-Disposition: attachment; filename*="gbk'''.$filename.'"');<li>} <li>else <li>{ <li>header('Content-Disposition: attachment; filename="'.$filename.'"');<li>}<li>ob_clean(); <li>flush();<li>readfile($filename);<li>echo 'rn您下载的文件由程序员之家编辑部提供!感谢您的下载。';<li>exit;<li>?></li> </ol></div> <em onclick="copycode($('code_exN'));">复制代码</em> </div> </td></tr></table> <div id="comment_45056" class="cm"> </div> <div id="post_rate_div_45056"></div> <br><br>