2017-07-30 91 views
0

当我尝试从URL和getimagesize和非拉丁字符

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 
+0

这已经在这里回答:https://stackoverflow.com/questions/20037694/getimagesize-does-not-work-with-images-that-c​​ontain-latin-special-chars –

回答

0

如果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"; 
} 
?> 
+0

好的,一个d如何从外部网址获取图片大小? –

+0

我试过这个代码,但仍然不工作 '$ path = pathinfo('https://example.com/storage/image图片20170214003852.jpg'); $ xx = getimagesize($ path ['dirname']。urlencode($ path ['basename']));' –

+0

试试上面修改后的代码.. –

相关问题