getimagesize & 非拉丁字符

getimagesize & non-Latin characters

当我尝试从 url

获取图像尺寸时
getimagesize('https://example.com/storage/image图片20170214003852.jpg')

我收到错误

PHP Warning:  getimagesize(https://example.com/storage/QQ\xe5\x9b\xbe\xe7\x89\x8720170214003852.jpg): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

如果您对文件名进行 urlencode,它会起作用:

<?php
$external_link = 'https://example.com/storage/'.urlencode('image图片20170214003852.jpg');
//$external_link = 'https://nikonrumors.com/wp-content/uploads/2014/03/Nikon-1-V3-sample-photo.jpg';
if (list($width, $height, $type, $attr) = @getimagesize($external_link)) {
  echo "Width=".$width. ', '."Height=".$height;
} else {
    echo  "image does not exist";
}
?>