PHPҵվfailed to open stream: HTTP request failed!ķ
һԭ
ʹphp5Դfile_get_contentsȡԶļʱʱfile_get_contents(): failed to open stream: HTTP request
failed!Ϣ googlebaiduһ£ö⣬ķphp.iniallow_url_fopenã
ʹphp5Դfile_get_contentsȡԶļʱʱfile_get_contents(): failed to open stream: HTTP request
failed!Ϣ
googlebaiduһ£ö⣬ķphp.iniallow_url_fopenãij allow_url_fopen = On
ԽijЩ˵⣬˵php.iniУѡ:allow_url_fopen =on(ʾͨurlԶļ)user_agent="PHP"
ʾֽͨű磬Ĭǰи " ; " ȥɡ
ЩǻϢĽһphp.iniuser_agentphpĬϵuser_agentPHPǰij
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)ģͿ
user_agent=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
ڹ⣬ʷҡ
ץȡchemblinkĽṹʽѭвͼƬʾԶļǴڵġ
ץȡԶļʱWarning: readfile(http://www.php100.com/logo.gif) [function.readfile]: failed to open stream: HTTP
request failed! ľϢʹõ
ob_start();
readfile("http://www.php100.com/logo.gif");
$img = ob_get_contents();
ob_end_clean();
лʱʱijҲfile_get_contentsûãϲĺCURLץȡ
$url = "http://www.php100.com/logo.gif";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
$img = curl_exec($ch);
ڶԭ
ҪPHPҵվдȨDzCMSվЩĿ¼ҪдȨģ