From d642560e30cb7252bd44cca0333b58413c7cf71f Mon Sep 17 00:00:00 2001 From: fredtempez Date: Fri, 10 Sep 2021 08:35:21 +0200 Subject: [PATCH] =?UTF-8?q?download=202.5=20bug=20t=C3=A9l=C3=A9chargement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/download/download.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/module/download/download.php b/module/download/download.php index 63ee2d6a..f615f2b4 100644 --- a/module/download/download.php +++ b/module/download/download.php @@ -14,7 +14,7 @@ class download extends common { - const VERSION = '2.4'; + const VERSION = '2.5'; const REALNAME = 'Téléchargement'; const DELETE = true; const UPDATE = '0.0'; @@ -923,9 +923,8 @@ class download extends common { } // Téléchargement else { - $filePath = 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($filePath)) { + $fileName = self::FILE_DIR . 'source/' . $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'file']); + if (file_exists($fileName)) { // Statistiques de téléchargement $statId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), 'items', $this->getUrl(2), 'stats'])); $this->setData(['module', @@ -938,14 +937,15 @@ class download extends common { 'ip' => helper::getIp() ]]); // Formatage http + header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename="' . $fileName . '"'); - header('Content-Length: ' . filesize($filePath)); - readfile( $filePath); - // Valeurs en sortie - $this->addOutput([ - 'display' => self::DISPLAY_RAW - ]); + header('Content-Disposition: attachment; filename="'.basename($fileName).'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . filesize($fileName)); + readfile($fileName); + exit; } else { // Valeurs en sortie $this->addOutput([