我正在获取图像字符串的基数 64,我必须移动文件夹并将图像路径存储在数据库中,但我必须限制文件大小。我该如何执行此操作:
我从 Base 64 字符串生成图像的代码如下:
/** if image is attached with request **/
$Image = "MyBase64StringHere";
list($type, $Image) = explode(';', $Image);
list(, $Image) = explode(',', $Image);
/** decode the base 64 image **/
$Image = base64_decode($Image);
I have tried to get image size like:
$size = getimagesize($Image);
但是从中获取文件的宽度和高度。有人可以告诉我如何从中获取文件大小。谢谢
请检查这个:
解码后,尝试使用以下命令:getimagesizefromstring()
,如果你和PHP 5.4
,如果使用PHP 5.3
,那么你可以用下面的方法来检查。
<?php
if (!function_exists('getimagesizefromstring')) {
function getimagesizefromstring($data)
{
$uri = 'data://application/octet-stream;base64,' . base64_encode($data);
return getimagesize($uri);
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)