mambax7/extcal

View on GitHub
download_attachement.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

use XoopsModules\Extcal\{Helper,
    FileHandler,
    Perm
};
use Xmf\Request;

require_once __DIR__ . '/header.php';
require_once __DIR__ . '/include/constantes.php';

$fileId = Request::getInt('file', 0, 'GET');

/** @var FileHandler $fileHandler */
$fileHandler = Helper::getInstance()->getHandler(_EXTCAL_CLN_FILE);

$file = $fileHandler->getFile($fileId);

header('Content-Type: ' . $file->getVar('file_mimetype') . '');
header('Content-Disposition: attachment; filename="' . $file->getVar('file_nicename') . '"');

readfile(XOOPS_ROOT_PATH . '/uploads/extcal/' . $file->getVar('file_name'));