From 050c6cfd0e75249ae7b7dad3f8ec6eed6be50102 Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 25 Apr 2016 11:40:28 +0200 Subject: * separating safer file upload trait to its own file --- app/php/components/SafeFileUploadMethods.php | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/php/components/SafeFileUploadMethods.php (limited to 'app/php/components/SafeFileUploadMethods.php') 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 @@ +_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(); + } + +} + +?> -- cgit v1.2.3