mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-24 15:28:41 +00:00
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.
This commit is contained in:
parent
3bc9419e3f
commit
2e3817cabe
@ -78,7 +78,8 @@ EOD;
|
||||
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||
}
|
||||
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('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||
}
|
||||
unlink($up_filename);
|
||||
//}else{
|
||||
//$errmsg = "请上传zip文件!";
|
||||
//becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||
//}
|
||||
}else{
|
||||
$errmsg = "请上传zip文件!";
|
||||
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user