Fails to load remote files from web, but not CLI
-
21-09-2019 - |
Question
I can load a remote file (http) from the php CLI:
php > print_r(getimagesize("http://www.google.ca/intl/en_ca/images/logo.gif"));
Array
(
[0] => 276
[1] => 110
[2] => 1
[3] => width="276" height="110"
[bits] => 8
[channels] => 3
[mime] => image/gif
)
However, the exact same code from a web script gives me:
[Thu Sep 03 21:47:53 2009] [error] [client 127.0.0.1] PHP Warning: getimagesize() [<a ref='function.getimagesize'>function.getimagesize</a>]: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /var/www/html/Whatsize/index.php on line 30
[Thu Sep 03 21:47:53 2009] [error] [client 127.0.0.1] PHP Warning: getimagesize(http://www.google.ca/intl/en_ca/images/logo.gif) [<a href='function.getimagesize'>function.getimagesize</a>]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /var/www/html/Whatsize/index.php on line 30
Do I have to change something in httpd.conf to allow remote file access?
Solution
I've (temporarily) at least solved the problem by restarting httpd. This seems to be a bug that's been floating around for a while.
http://www.scottklarr.com/topic/98/temporary-failure-in-name-resolution-in-php-script/
If anyone has a more permanent solution, please reply. My web host does not seem to have this problem, so it's a good enough solution for me to test with.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow