有没有办法通过上传图片获取图片尺寸(宽度,高度):
CHtml::activeFileField(CModel $model, string $attribute, array $htmlOptions=array ( ))
以及稍后:
CUploadedFile getInstance(CModel $model, string $attribute)
很遗憾,我找不到任何有用的信息here
任何想法?或者我应该使用原始的PHP方法吗?
答案 0 :(得分:3)
您可以使用本机php函数getimagesize()。 在你的情况下:
$imageInfo = getimagesize(CUploadedFile::getInstance($model,'attributeName')->getTempName());
$ image info变量返回数组,其中0和1元素分别是当前图像的宽度和高度
答案 1 :(得分:0)