public function upload(string $fileKey)
    {
        if (!isset($this->uploadedFiles[$fileKey])) {
            throw new Exception('PitonCMS: File upload key does not exist');
        }

        $file = $this->uploadedFiles[$fileKey];

        if ($file->getError() === UPLOAD_ERR_OK) {
            // Get file name and extension
            $uploadFileName = $file->getClientFilename();
            $ext = strtolower(pathinfo($uploadFileName, PATHINFO_EXTENSION));

            // Create new file name and directory and ensure it is unique
            do {
                $name = $this->generateName();
                $path = $this->getFilePath($name);
                $exists = $this->makeFileDirectory($path);
            } while (!$exists);

            $this->fileName = "$name.$ext";
            $file->moveTo("{$this->publicRoot}{$path}{$this->fileName}");

            unset($file);

            return true;
        }

        // Save error code
        $this->error = $file->getError();

        return false;
    }