Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to restrict uploads to mime type, filename and maximu…
…m size usage exampe: $this->addResource(new Kwf_Acl_Resource_MediaUpload('upload_image', 'image/.*', '(jpe?g|png|gif)$', 1024*1024*10)); or (the same): $this->addResource(new Kwf_Acl_Resource_MediaUpload_Image('upload_image', 1024*1024*10)); (10MB is the maximum file size (optional))
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
class Kwf_Acl_Resource_MediaUpload extends Zend_Acl_Resource | ||
{ | ||
private $_mimeTypePattern; | ||
private $_filenamePattern; | ||
private $_maxFilesize; | ||
|
||
public function __construct($resourceId, $mimeTypePattern, $filenamePattern, $maxFilesize = null) | ||
{ | ||
$this->_mimeTypePattern = $mimeTypePattern; | ||
$this->_filenamePattern = $filenamePattern; | ||
$this->_maxFilesize = $maxFilesize; | ||
parent::__construct($resourceId); | ||
} | ||
|
||
public function getMimeTypePattern() | ||
{ | ||
return $this->_mimeTypePattern; | ||
} | ||
public function getFilenamePattern() | ||
{ | ||
return $this->_filenamePattern; | ||
} | ||
public function getMaxFilesize() | ||
{ | ||
return $this->_maxFilesize; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
class Kwf_Acl_Resource_MediaUpload_Image extends Kwf_Acl_Resource_MediaUpload | ||
{ | ||
public function __construct($resourceId, $maxFilesize = null) | ||
{ | ||
parent::__construct($resourceId, 'image/.*', '(jpe?g|png|gif)$', $maxFilesize); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters