/** * @return mixed|string */ public function getFileName() { if (!$this->fileName) { $this->fileName = pathinfo($this->filePath, PATHINFO_BASENAME); $this->fileName = FileUtil::filterFileName($this->fileName); } return $this->fileName; }
/** * @param $field */ public function __construct($field) { if (empty($_FILES[$field])) { throw new InvalidArgumentException('file not uploaded as ' . $field . ' check if your form is uploading file with name attribute as ' . $field); } $fileInfo = $_FILES[$field]; $this->fileName = FileUtil::filterFileName(pathinfo($fileInfo['name'], PATHINFO_BASENAME)); $this->filePath = $fileInfo['tmp_name']; $this->fileSize = intval($fileInfo['size']); $this->mimeType = $fileInfo['type']; }