email = $email; $this->sendFile = $sendFile; } public function validate(): bool { if (!empty($this->email) && !filter_var($this->email, FILTER_VALIDATE_EMAIL)) { return false; } if ($this->sendFile['size'] > 5242880) { echo "Недопустимо большой размер файла"; return false; } if (!empty($this->sendFile['name']) && $this->sendFile['type'] !== 'application/pdf') { echo "Используйте файл с расширением *.pdf"; return false; } return parent::validate(); } public function uploadFiles(): void { $uploadDirectory = dirname(__DIR__, 1) . '/file/'; if (!file_exists($uploadDirectory)) { mkdir($uploadDirectory, 0777); $way = $uploadDirectory . time() . $this->sendFile['name']; move_uploaded_file($this->sendFile['tmp_name'], $way); } else { $way = $uploadDirectory . time() . $this->sendFile['name']; move_uploaded_file($this->sendFile['tmp_name'], $way); } } public function send() { parent::send(); if (!empty($this->email)) { echo '
'; echo 'Email: ' . $this->email; } } }