download 2.5 bug téléchargement

This commit is contained in:
Fred Tempez 2021-09-10 08:35:21 +02:00
parent fc11676d02
commit d642560e30

View File

@ -14,7 +14,7 @@
class download extends common { class download extends common {
const VERSION = '2.4'; const VERSION = '2.5';
const REALNAME = 'Téléchargement'; const REALNAME = 'Téléchargement';
const DELETE = true; const DELETE = true;
const UPDATE = '0.0'; const UPDATE = '0.0';
@ -923,9 +923,8 @@ class download extends common {
} }
// Téléchargement // Téléchargement
else { else {
$filePath = self::FILE_DIR . 'source/' . $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'file']); $fileName = self::FILE_DIR . 'source/' . $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'file']);
$fileName = $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'file']); if (file_exists($fileName)) {
if (file_exists($filePath)) {
// Statistiques de téléchargement // Statistiques de téléchargement
$statId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'stats'])); $statId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'stats']));
$this->setData(['module', $this->setData(['module',
@ -938,14 +937,15 @@ class download extends common {
'ip' => helper::getIp() 'ip' => helper::getIp()
]]); ]]);
// Formatage http // Formatage http
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $fileName . '"'); header('Content-Disposition: attachment; filename="'.basename($fileName).'"');
header('Content-Length: ' . filesize($filePath)); header('Expires: 0');
readfile( $filePath); header('Cache-Control: must-revalidate');
// Valeurs en sortie header('Pragma: public');
$this->addOutput([ header('Content-Length: ' . filesize($fileName));
'display' => self::DISPLAY_RAW readfile($fileName);
]); exit;
} else { } else {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([