public function getUploadDir($subdir = null)
    {
        $dir = GEMS_ROOT_DIR . '/var/uploads';

        if ($subdir) {
            if (($subdir[0] == '/') || ($subdir[0] == '\\') || (substr($subdir, 1, 2) == ':\\')) {
                $dir = rtrim($subdir, '\//');
            } else {
                $dir .= DIRECTORY_SEPARATOR . rtrim($subdir, '\//');
            }
        }

        if (! is_dir($dir)) {
            $oldmask = umask(0777);
            if (! @mkdir($dir, 0777, true)) {
                $this->throwLastError(sprintf($this->translate->_("Could not create '%s' directory."), $dir));
            }
            umask($oldmask);
        }

        return $dir;
    }