简体   繁体   English

getimagesize / fopen 连接被拒绝

[英]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.我正在尝试使用本地 php function getimagesize 从绝对 URL 的远程图像中获取大小。 I am using PHP 7.3, here is the code:我正在使用 PHP 7.3,这里是代码:

$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:使用 fopen,同样的问题:

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.当我从另一台服务器尝试相同的 URL 时,它正在工作。

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. allow_url_fopen 已启用。 I think that it should come from Apache conf, but not sure... Anybody has an idea?我认为它应该来自 Apache conf,但不确定......有人有想法吗? Thanks !谢谢 !

Finally, the problem is coming from the network.最后,问题来自网络。 Apache could not resolve his own public domain name. Apache 无法解析自己的公共域名。 So to correct the problem, I just had " 127.0.0.1 mydomain" in the hosts file, and the problem was solved.所以为了纠正这个问题,我只是在hosts文件中有“127.0.0.1 mydomain”,问题就解决了。 Hope it can help !希望它可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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