【发布时间】:2023-03-10 08:30:02
【问题描述】:
我正在使用 laravel 的干预包来上传图像,并且我创建了一个虚拟主机登台服务器,我在其中托管了我的项目。 当我在具有虚拟主机的本地计算机上使用干预时,干预工作正常。
我遇到以下错误:
AbstractDecoder.php 第 64 行中的 ErrorException:file_get_contents(): php_network_getaddresses: getaddrinfo failed: No such host is known.
位于\vendor\intervention\image\src\Intervention\Image\AbstractDecoder.php 中的以下代码
/**
* Init from fiven URL
*
* @param string $url
* @return \Intervention\Image\Image
*/
public function initFromUrl($url)
{
if ($data = file_get_contents($url)) {
return $this->initFromBinary($data);
}
throw new \Intervention\Image\Exception\NotReadableException(
"Unable to init from given url (".$url.")."
);
}
我认为当我们在虚拟主机上工作时,file_get_content 会出现问题。 我已经提到了这个Question,但我没有得到解决方案。
【问题讨论】:
-
这看起来像是 DNS 问题。请您尝试将 URL 作为 IP 地址而不是服务器名称传递。如果这可行,那么它肯定是 DNS 问题,然后我们会努力解决这个问题。
-
@EddeAlmeida 它适用于 IP。不能使用虚拟主机的假域名。
-
然后我们遇到了 DNS 问题,正如我之前所说。您使用的是什么操作系统?
-
我在服务器和本地系统上都使用 Windows 7 来访问项目。
-
然后您必须编辑 Windows 7 解析本地 DNS 名称的文件并将 IP 映射到相应的虚拟服务器。请阅读:helpdeskgeek.com/windows-xp-tips/edit-hosts-file
标签: php laravel-5.2 virtualhost file-get-contents intervention