2

当我在我的应用程序中使用函数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。

4

1 回答 1

0

该图片是在您的应用程序中还是在网络上的其他位置都没有关系,因为您使用的是图像 URL。该错误还与从 Web 获取一些内容有关,这些内容最好由curl.

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

于 2020-06-05T09:20:29.987 回答