Skip to content

Commit

Permalink
Merge pull request #4 from janki1/feature/check-mimetype
Browse files Browse the repository at this point in the history
Add option checkMimeType
  • Loading branch information
janki1 authored Aug 9, 2022
2 parents 929a3c8 + c51096e commit af472b4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ Module configure
---
### Property

* 'roles' array|null Allowed user roles to access this module. Default only logged user. See https://www.yiiframework.com/doc/api/2.0/yii-filters-accessrule#$roles-detail
* `roles` array|null Allowed user roles to access this module. Default only logged user. See https://www.yiiframework.com/doc/api/2.0/yii-filters-accessrule#$roles-detail
* `uploadFolder` the directory where stored files. Default is `@app/web/uploads/images`. If folder not existed, roxy will auto-create it.
* `uploadUrl` the url which can get folder link. Default is `/uploads/images`. If you are using `yii2-advanced` should include scheme (`http://frontend.domain.com/uploads/images`).
* `defaultView` display type. Default is `thumb`
* `dateFormat` Datetime format. Default is `Y-m-d H:i`. See: http://php.net/manual/en/function.date.php
* `rememberLastFolder` would you want to remember last folder? Default is `true`
* `rememberLastOrder` would you want to remember last order? Default is `true`
* `allowExtension` allowed files extension. Default is `jpeg jpg png gif mov mp3 mp4 avi wmv flv mpeg webm`
* `checkMimeType` bool check mime type of uploaded files

### Example
Add to config file:
Expand Down
7 changes: 6 additions & 1 deletion src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ class Module extends BaseModule
* @var string default allowed files extension
*/
public $allowExtension = 'jpeg jpg png gif svg mov mp3 mp4 avi wmv flv mpeg webm ogg';


/**
* @var bool check mime type of uploaded files
*/
public $checkMimeType = true;

/**
* Initializes the module.
*
Expand Down
1 change: 1 addition & 0 deletions src/models/UploadForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function rules()
'skipOnEmpty' => true,
'extensions' => implode(',', explode(' ', $module->allowExtension)),
'maxFiles' => 20,
'checkExtensionByMimeType' => $module->checkMimeType
],
];
}
Expand Down

0 comments on commit af472b4

Please sign in to comment.