本文整理汇总了PHP中ActiveRecord::getMaxFileSize方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::getMaxFileSize方法的具体用法?PHP ActiveRecord::getMaxFileSize怎么用?PHP ActiveRecord::getMaxFileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::getMaxFileSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
{
return array(array('listing_id', 'numerical', 'integerOnly' => true), array('file', 'length', 'max' => 255), array('file', 'file', 'allowEmpty' => true, 'types' => 'pdf,doc,docx,xls,xlsx,txt', 'wrongType' => 'Only pdf,doc,docx,xls,xlsx,txt are allowed.', 'maxSize' => ActiveRecord::getMaxFileSize(), 'tooLarge' => 'The file was larger than 10 MB. Please upload a smaller file.'), array('id, listing_id, file, created_date', 'safe'));
}
示例4: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(array('name', 'required'), array('name', 'length', 'max' => 255), array('id, name, order_at, cover, status, course_id, slug, short_description, description', 'safe'), array('imageFile', 'file', 'on' => 'create,update', 'allowEmpty' => true, 'types' => 'jpg,gif,png', 'wrongType' => 'Only jpg,gif,png are allowed.', 'maxSize' => ActiveRecord::getMaxFileSize(), 'tooLarge' => 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.'));
}
示例5: 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);
}
示例6: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(array('title', 'required'), array('external_link', 'validateLink'), array('status, layout_id, user_id, order', 'numerical', 'integerOnly' => true), array('title', 'length', 'max' => 200), array('post_type', 'length', 'max' => 20), array('featured_image', 'length', 'max' => 250), array('slug', 'length', 'max' => 250), array('id, title, show_footer,show_home_page, content, status, layout_id, user_id, post_type, meta_keywords, meta_desc, featured_image, order, created, modified, slug, title_tag, external_link', 'safe'), array('imageFile', 'file', 'on' => 'create,update', 'allowEmpty' => true, 'types' => 'jpg,gif,png', 'wrongType' => 'Only jpg,gif,png are allowed.', 'maxSize' => ActiveRecord::getMaxFileSize(), '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: &%$#'), array('thumbFile', 'file', 'on' => 'create,update', 'allowEmpty' => true, 'types' => 'jpg,gif,png', 'wrongType' => 'Only jpg,gif,png are allowed.', 'maxSize' => ActiveRecord::getMaxFileSize(), 'tooLarge' => 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.'), array('thumbFile', 'match', 'pattern' => '/^[^\\/?*:&;{}\\\\]+\\.[^\\/?*:;{}\\\\]{3}$/', 'message' => 'Thumb files name cannot include special characters: &%$#'), array('banner', 'file', 'allowEmpty' => true, 'types' => 'jpg, jpeg, gif, png', 'maxSize' => ActiveRecord::getMaxFileSize(), 'wrongType' => 'Only jpg, jpeg, gif, png are allowed.', 'tooLarge' => 'The file was larger than ' . ActiveRecord::getMaxFileSize() / 1024 . ' KB. Please upload a smaller file.', 'on' => 'create, update'));
}
示例7: rules
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
return array(array('listing_id, default', 'numerical', 'integerOnly' => true), array('FileValidate', 'file', 'allowEmpty' => true, 'types' => ProListingPhotos::$AllowFile, 'wrongType' => 'Only ' . ProListingPhotos::$AllowFile . ' are allowed.', 'maxSize' => ActiveRecord::getMaxFileSize(), 'tooLarge' => 'The file was larger than 10 MB. Please upload a smaller file.'), array('display_order,id, listing_id, default, image, created_date', 'safe'));
}
示例8: 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;
}