I am familar with PHP but not so much with CGI. There is a page that I would like to get the contents from (specifically one that has just a jpg image) that has the extension .cgi
My question: is there a way to get the contents(or image) from a CGI page using PHP? Using file_get_contents($url) and imagecreatefromjpeg($url) gives me an error that says it failed to open the stream however I am able to right click on the image and save it as a jpg. I assume that is because the browser can recognize it as an image.
EDIT: My problem might be that the connection is just timing out.
尝试将fopen()与二进制模式标志一起使用,然后将fwrite()与其他.jpg文件名一起使用。
You could try using cURL for that, which is somewat faster then file_get_contents:
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,$yourUrlHere);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
Hope it helps
Other cgi pages that I have tried getting using file_get_contents and curl have worked for me. It seems that just this particular page doesn't work for some reason. I assume that it is just a connection issue that prevents me from doing so.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.