getimagesize():php_network_getaddresses:Yii中的getaddrinfo失败

问题描述 投票:2回答:1

当我在应用程序中使用函数getimagesizeimagecreatefromjpeg链接时,向我发送错误:

getimagesize():php_network_getaddresses:getaddrinfo失败:名称或服务未知

这是我的代码:

         // tidy up by removing temporary image
            unlink($tempname);
             return $retvars;
         }

         /**
          * Extract info from a JPEG file without using the GD library.
          * @param $file (string) image file to parse
          * @return array structure containing the image data
          * @public static
          */
         public static function _parsejpeg($file) {
             $a = getimagesize($file);
             if (empty($a)) {
                 //Missing or incorrect image file
                 return false;
             }
             if ($a[2] != 2) {
                 // Not a JPEG file
                 return false;
             }
             // bits per pixel
             $bpc = isset($a['bits']) ? intval($a['bits']) : 8;
             // number of image channels
             if (!isset($a['channels'])) {

确切地说,当我在地址栏中复制图像的链接时,它就会出现并存在。我的PHP版本是5.3.3。

php yii getimagesize getaddrinfo
1个回答
0
投票
该图片是在您的应用中还是在网络上的其他位置都没有关系,因为您使用的是图片网址。该错误还与从网络上获取一些内容有关,最好由curl处理。

您需要做的是使用文件系统中的图像地址。

© www.soinside.com 2019 - 2024. All rights reserved.