<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_30634"> <div class="blockcode"> <div id="code_ns8"><ol> <li> <li><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> </li> <li><html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn"> </li> <li><head> </li> <li><title>php下载文件函数</title></li> <li><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </li> <li><meta http-equiv="Content-Language" content="UTF-8" /> </li> <li></head> </li> <li><form method="post"> </li> <li><input name="url" size="20" /> </li> <li><input name="submit" type="submit" /> </li> <li><!-- <input type="hidden" name="MAX_FILE_SIZE" value="2097152" />--> </li> <li></form> </li> <li><?php<li> set_time_limit(24*60*60);<li> if (!isset($_POST['submit'])) die ();<li> $destination_folder = './down/'; // 文件夹保存下载文件。必须以斜杠结尾<li> $url = $_POST['url'];<li> $newfname = $destination_folder.basename($url);<li> $file = fopen($url, "rb");<li> if ($file) {<li> $newf = fopen($newfname, "wb");<li> if ($newf) while (!feof($file)) {<li> fwrite($newf, fread($file, 1024*8), 1024*8);<li> }<li> }<li> if ($file) {<li> fclose($file);<li> }<li> if ($newf) {<li> fclose($newf);<li> }<li>?></li> </ol></div> <em onclick="copycode($('code_ns8'));">复制代码</em> </div> </td></tr></table> <div id="comment_30634" class="cm"> </div> <div id="post_rate_div_30634"></div> <br><br>