Reputation: 5055
I am using intervention package of laravel to upload images and I have created a virtual host staging server where I have hosted my project. Intervention is working fine when I am using it on local machine with virtual host.
I am getting below error:
ErrorException in AbstractDecoder.php line 64: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No such host is known.
Which is in below code in \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.")."
);
}
I think file_get_content gives problem when we work on virtual host. I have referred this Question but I didn't get solution.
Upvotes: 1
Views: 3878
Reputation: 3723
If file_get_contents
works when you use IPs but not when you use virtual host names, then we have a DNS issue here.
If you were using Linux you should edit (as root) the file /etc/hosts
and map there the names of your virtual servers to the corresponding IPs and then restart your DNS servers.
But you are using Windows 7, then you must do the same in the file C:\Windows\System32\Drivers\etc\hosts
and then restart your machine machine.
If you have doubts about how to find/edit this file, please read this article here.
Upvotes: 1