$image_info = getimagesize($_FILES["image"]["tmp_name"]);
$image_width = $image_info[0];
$image_height = $image_info[1];
这是我的CMultiFileUpload文件字段。
<?php
$this->widget('CMultiFileUpload', array(
'model'=>$model,
'name'=>'image',
'attribute'=>'image',
'accept'=>'jpeg|jpg|gif|png',
'denied'=>'Only jpg,gif and png are allowed',
'max'=>4,
'remove'=>'[x]',
'duplicate'=>'Already Selected',
));
?>
答案 0 :(得分:0)
您可以在onFileSelect函数中设置大小
$this->widget('CMultiFileUpload',
array(
'name' => 'property_floor_plans',
'model' => $model,
'max' => $fimgCount,
'accept' => 'jpeg|jpg|gif|png', // useful for verifying files
'duplicate' => 'Duplicate file!', // useful, i think
'denied' => 'Invalid file type', // useful, i think
'htmlOptions' => array('style' => "margin-left:15px;$options"),
'options' => array(
'onFileSelect'=>'function(e ,v ,m){
var fileSize = e.files[0].size;
fileSize = (fileSize/1024);
if(fileSize>imgLimit){
alert("Exceeds file upload limit 2MB");
return false;
}
return true;
}',
)
));