Google or Baidu, a lot of such problems, the solution is to modify the php.ini, the Allow_url_fopen to enable, change to Allow_url_fopen = On
This can solve some people's problems, it is said in PHP.ini, there are two options: Allow_url_fopen =on (indicating that the remote file can be opened via a URL), user_agent= "PHP" (indicating which script to access the network, the default is preceded by a ";" Remove. ) Restart the server.
But some will have this warning message, want to use the perfect solution is one step, but also to set the php.ini inside the user_agent,php default user_agent is PHP, we change it to mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) to simulate the browser is available
User_agent= "mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) "
In the work encountered this problem, after the perfect solution, so share to everyone.
I batch crawl Chemblink the structure of the discovery loop after some pictures can not be displayed, and remote files exist.
Crawling remote files appears similar to Warning:readfile (http://www.jb51.net/logo.gif) [Function.readfile]: Failed to open stream:http request failed! Such a warning message that I am using is
Copy the Code code as follows:
Ob_start ();
ReadFile ("Http://www.jb51.net/logo.gif");
$img = Ob_get_contents ();
Ob_end_clean ();
In this way in the run will occasionally appear the above error, I also changed file_get_contents and other functions are useless, after online review found that using the curl method to crawl without error
Now more popular with curl
Copy the Code code as follows:
$url = "Http://s.jb51.net";
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, curlopt_connecttimeout,10);
$dxycontent = curl_exec ($ch);
Echo $dxycontent;
?>
The above describes the Request.QueryString PHP error hint failed to open Stream:http request failed! perfect solution, Includes the content of request.querystring, hope to be interested in PHP tutorial friends helpful.