diff options
author | emkael <emkael@tlen.pl> | 2016-04-25 11:40:28 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-04-25 11:40:28 +0200 |
commit | 050c6cfd0e75249ae7b7dad3f8ec6eed6be50102 (patch) | |
tree | db6076f9edeccf9c2a867e87a42ff6f756f1603c /app/php/components/SafeFileUploadMethods.php | |
parent | dd5aaa4db1e8758652586aa82f21bf631ce20bcc (diff) |
* separating safer file upload trait to its own file
Diffstat (limited to 'app/php/components/SafeFileUploadMethods.php')
-rw-r--r-- | app/php/components/SafeFileUploadMethods.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/php/components/SafeFileUploadMethods.php b/app/php/components/SafeFileUploadMethods.php new file mode 100644 index 0000000..bdb2af6 --- /dev/null +++ b/app/php/components/SafeFileUploadMethods.php @@ -0,0 +1,32 @@ +<?php + +trait SafeFileUploadMethods { + + protected $_isSecure = TRUE; + + public function getIsSecure() { + return $this->_isSecure; + } + + public function setIsSecure($bool) { + $this->_isSecure = $bool; + } + + public function getFileType() { + if ($this->getIsSecure()) { + $fileInfo = new finfo(FILEINFO_MIME_TYPE); + return $fileInfo->file($this->getLocalName()); + } + return parent::getFileType(); + } + + public function getFileSize() { + if ($this->getIsSecure()) { + return filesize($this->getLocalName()); + } + return parent::getFileSize(); + } + +} + +?> |