Php yii框架中的图像维

Php yii框架中的图像维,php,file-upload,yii,Php,File Upload,Yii,是否可以通过以下方式通过上传图像获得图像尺寸(宽度、高度): CHtml::activeFileField(CModel $model, string $attribute, array $htmlOptions=array ( )) 以及后来的: CUploadedFile getInstance(CModel $model, string $attribute) 不幸的是,我找不到任何有用的信息 有什么想法吗?还是应该使用原始php方法?您可以使用本机php函数getimagesize(

是否可以通过以下方式通过上传图像获得图像尺寸(宽度、高度):

CHtml::activeFileField(CModel $model, string $attribute, array $htmlOptions=array ( ))
以及后来的:

CUploadedFile getInstance(CModel $model, string $attribute)
不幸的是,我找不到任何有用的信息


有什么想法吗?还是应该使用原始php方法?

您可以使用本机php函数getimagesize()。 就你而言:

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

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

我昨天刚刚需要这个

只需使用此扩展:


按照页面中的安装和使用说明进行操作。

您需要图像处理驱动程序/库来获取imagegetInstance($model)或getInstance($model,'field_name')的维度?