mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-24 18:48:40 +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>');
|
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||||
}
|
}
|
||||||
else{
|
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";
|
$up_filename="/tmp/".rand(0,100000000)."data.zip";
|
||||||
move_uploaded_file($_FILES["problem_data_file"]["tmp_name"], $up_filename);
|
move_uploaded_file($_FILES["problem_data_file"]["tmp_name"], $up_filename);
|
||||||
$zip = new ZipArchive;
|
$zip = new ZipArchive;
|
||||||
@ -92,10 +93,10 @@ EOD;
|
|||||||
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||||
}
|
}
|
||||||
unlink($up_filename);
|
unlink($up_filename);
|
||||||
//}else{
|
}else{
|
||||||
//$errmsg = "请上传zip文件!";
|
$errmsg = "请上传zip文件!";
|
||||||
//becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user