$url="/admin/upload/client.jpg";
$urlRs = explode("/", $url);
$filename=$url[count($urlRs)-1];$fileurl="http://".$_SERVER['SERVER_NAME'].$url;header('Content-Disposition:attachment;filename='.$filename);
header("Content-type: text/html");
echo file_get_contents("http://www.aaa.com".$fileurl);//or echo file_get_contents($_SERVER[“DOCUMENT_ROOT”].$fileurl);
注意file_get_contents:要么给http:全路径,要么用绝对路径,尽量不要用相对路径
$urlRs = explode("/", $url);
$filename=$url[count($urlRs)-1];$fileurl="http://".$_SERVER['SERVER_NAME'].$url;header('Content-Disposition:attachment;filename='.$filename);
header("Content-type: text/html");
echo file_get_contents("http://www.aaa.com".$fileurl);//or echo file_get_contents($_SERVER[“DOCUMENT_ROOT”].$fileurl);
注意file_get_contents:要么给http:全路径,要么用绝对路径,尽量不要用相对路径
可以先echo一下传入file_get_contents的路径看对不对
这个和"http://www.aaa.com".$fileurl是不是重了啊
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=$filename");
header("Content-Transfer-Encoding: binary");
readfile($fileurl);
echo $fileurl;
看看。
header("Content-Disposition: attachment;filename=$filename");
readfile($fileurl);
$urlRs = explode("/", $url);
$filename=$url[count($urlRs)-1];$fileurl="http://".$_SERVER['SERVER_NAME'].$url;
echo $fileurl;header( "Content-Type: application/force-download ");
header( "Content-Disposition: attachment; filename= ".basename($filename));
$data = file_get_contents($fileurl);
echo $data;
直接用 readfile(...)
echo file_get_contents($fileurl);
但是推荐用readfile进行读取(下载),不用file_get_contents储存到内存再下载,readfile直接输出,代码:
readfile($fileurl);