本文整理汇总了PHP中ActiveRecord::getMaxFileSizeImage方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::getMaxFileSizeImage方法的具体用法?PHP ActiveRecord::getMaxFileSizeImage怎么用?PHP ActiveRecord::getMaxFileSizeImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::getMaxFileSizeImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rules
public function rules()
{
return array(array('limit, offset, sort, key', 'safe'), array('title, name_for_slug, phone, email_not_login, ' . 'agent_cea, location_id, updatedCea, agreeTerm', 'required', 'on' => 'register', 'message' => 'This is required field'), array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements(), 'on' => 'register'), array('uploadPhoto, uploadNricFront, uploadNricBack', 'file', 'on' => 'register', 'allowEmpty' => true, 'types' => 'jpg,gif,png', 'wrongType' => 'Only jpg,gif,png are allowed.', 'maxSize' => ActiveRecord::getMaxFileSizeImage(), 'tooLarge' => 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.'));
}
示例2: validateFileUpload
public static function validateFileUpload($file, $attribute, $type)
{
if ($type = 'image') {
$mime = array('jpg', 'gif', 'png', 'jpeg');
}
if ($type = 'file') {
$mime = array('doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'txt' => 'text/plain');
}
if ($file["error"][$attribute][0] > 0) {
return "File error ";
} else {
$type = explode("/", $file["type"][$attribute][0]);
$size = $file["size"][$attribute][0];
$errType = 'File is not allowed';
$errMaxFile = 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.';
if ($type == 'image') {
if (!in_array(strtolower($type[1]), $mime)) {
return $errType;
}
}
if ($type == 'file') {
if (!in_array($type[1], $mime)) {
return $errType;
}
}
if ($size > ActiveRecord::getMaxFileSizeImage()) {
return $errMaxFile;
}
}
}
示例3: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
$rules = array(array('imageFile', 'file', 'on' => 'create,update', 'allowEmpty' => true, 'types' => 'jpg,gif,png', 'wrongType' => 'Only jpg,gif,png are allowed.', 'maxSize' => ActiveRecord::getMaxFileSizeImage(), 'tooLarge' => 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.'), array('imageFile', 'match', 'pattern' => '/^[^\\/?*:&;{}\\\\]+\\.[^\\/?*:;{}\\\\]{3}$/', 'message' => 'Image files name cannot include special characters: &%$#'));
return array_merge(parent::rules(), $rules);
}
示例4: getAdsBannerByType
* @return Banners the static model class
*/
public static function getAdsBannerByType($type)
{
$model = self::model()->findAll(array('condition' => 'status = 1 AND banner_type = ' . $type, 'order' => 'created_date'));
return $model;
}