From 2e3817cabe2236c9ae8a2885c75943ac158c498f Mon Sep 17 00:00:00 2001 From: Masco Skray Date: Tue, 16 Apr 2019 21:12:52 +0800 Subject: [PATCH] fix(uoj/1/app/controllers): fix problem data upload zip type detection error In the previous version when upload a zip online, even if it is a real zip file the system refuses to accept. Just simply disabled this function but it is not suitable. We found that there is not just one MIME type for zip file. So we add another common zip MIME types to temporarily solve it. --- uoj/1/app/controllers/problem_data_manage.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/uoj/1/app/controllers/problem_data_manage.php b/uoj/1/app/controllers/problem_data_manage.php index a9c3d7d..a7a225a 100644 --- a/uoj/1/app/controllers/problem_data_manage.php +++ b/uoj/1/app/controllers/problem_data_manage.php @@ -78,7 +78,8 @@ EOD; becomeMsgPage('
' . $errmsg . '
返回'); } else{ - //if($_FILES["problem_data_file"]["type"]=='application/zip'){ + $zip_mime_types = array('application/zip', 'application/x-zip', 'application/x-zip-compressed'); + if(in_array($_FILES["problem_data_file"]["type"], $zip_mime_types)){ $up_filename="/tmp/".rand(0,100000000)."data.zip"; move_uploaded_file($_FILES["problem_data_file"]["tmp_name"], $up_filename); $zip = new ZipArchive; @@ -92,10 +93,10 @@ EOD; becomeMsgPage('
' . $errmsg . '
返回'); } unlink($up_filename); - //}else{ - //$errmsg = "请上传zip文件!"; - //becomeMsgPage('
' . $errmsg . '
返回'); - //} + }else{ + $errmsg = "请上传zip文件!"; + becomeMsgPage('
' . $errmsg . '
返回'); + } } }