yii框架中的图像维度

时间:2014-06-13 15:04:35

标签: php file-upload yii

有没有办法通过上传图片获取图片尺寸(宽度,高度):

CHtml::activeFileField(CModel $model, string $attribute, array $htmlOptions=array ( ))

以及稍后:

CUploadedFile getInstance(CModel $model, string $attribute)

很遗憾,我找不到任何有用的信息here

任何想法?或者我应该使用原始的PHP方法吗?

2 个答案:

答案 0 :(得分:3)

您可以使用本机php函数getimagesize()。 在你的情况下:

$imageInfo = getimagesize(CUploadedFile::getInstance($model,'attributeName')->getTempName());

$ image info变量返回数组,其中0和1元素分别是当前图像的宽度和高度

答案 1 :(得分:0)

我昨天只需要这个。

只需使用此扩展程序:Image Yii Extension

按照说明在页面中安装和使用。