简体   繁体   中英

getimagesize / fopen connection refused

I am trying to get the size from an remote image with the native php function getimagesize from an absolute URL. I am using PHP 7.3, here is the code:

$fichier = 'http://mydomain/images/image.jpg';
$size = getimagesize($fichier);
var_dump($size);

And the code return:

PHP Warning: getimagesize(http://mydomain/images/image.jpg): failed to open stream: Connection refused in ...

And with fopen, same problem:

PHP Warning: fopen(http://mydomain/images/image.jpg): failed to open stream: Connection refused 

And when I am trying the same URL from an other server, it is working.

Also, if I am trying to get infos from an other image and from an other domain but on the same server, it is not working also.

allow_url_fopen is enabled. I think that it should come from Apache conf, but not sure... Anybody has an idea? Thanks !

Finally, the problem is coming from the network. Apache could not resolve his own public domain name. So to correct the problem, I just had " 127.0.0.1 mydomain" in the hosts file, and the problem was solved. Hope it can help !

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM