-
file_get_contents在指抓取的时候会出现很多问题,我以前也遇到过,不过都没有解决,后来改成了curl就没有出现这个问题了,建议你用CURL试试。
-
$url = "http://test.cc.com/test/test.jpg"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10); $str= curl_exec($ch); header("Content-type: text/plain"); header("Accept-Ranges: bytes"); header("Content-Disposition: attachment; filename="test.jpg"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0" ); header("Pragma: no-cache" ); header("Expires: 0" ); exit($str);