php 下载保存文件保存到本地
时间:2011-03-30 来源:龙圆
<?php
function downfile()
{
$filename=realpath("resume.html");
Header( "Content-type: application/octet-stream ");
Header( "Accept-Ranges: bytes ");
Header( "Accept-Length: " .filesize($filename));
Header( "Content-Disposition: attachment; filename= 4.html");
echo file_get_contents($filename);
readfile($filename);
}
downfile();
?>
<?php
function downfile($fileurl)
{
$filename=$fileurl;
$file = fopen($filename, "rb");
Header( "Content-type: application/octet-stream ");
Header( "Accept-Ranges: bytes ");
Header( "Content-Disposition: attachment; filename= 4.doc");
$contents = "";
while (!feof($file)) {
$contents .= fread($file, 8192);
}
echo $contents;
fclose($file);
}
$url=$_REQUEST['url'];
$url="http://www.bioonjob.com/bioon758/showdetail7.asp?id=17182";
downfile($url);
?>