From aab5ce503aebf4830c5f66ab958b01fb2c9857f0 Mon Sep 17 00:00:00 2001 From: Jeannick94 Date: Wed, 5 May 2021 17:49:16 +0800 Subject: [PATCH] Mabasa, Samantha, and Nafis - Fixed Bug 201 Unable to download an attachment from a student's submission (file name containing commas) --- Download.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Download.php b/Download.php index 71b49bd..1b6e1f8 100644 --- a/Download.php +++ b/Download.php @@ -8,7 +8,7 @@ session_start(); // 修改这一行设置你的文件下载目录 $file = "./../../lrr_submission".$_GET['file']; -$filename = basename($file); +$filename =basename($file); // 判断文件是否存在 if(!file_exists($file)) die("File does not exist."); @@ -22,8 +22,9 @@ $time = time(); if ( (isset($_SESSION["user_student_id"]) && strpos($file, $_SESSION["user_student_id"])) || $_SESSION['user_type'] == "Lecturer" || $_SESSION['user_type'] == "TA") { // 发送文件头部 + header("Content-type: $type"); - header("Content-Disposition: attachment;filename=$filename"); + header('Content-Disposition: attachment;filename="'.urldecode($filename).'"' ); header("Content-Transfer-Encoding: binary"); header('Pragma: no-cache'); header('Expires: 0');