new fille handler

This commit is contained in:
2021-03-09 15:04:59 +01:00
parent a69890c970
commit 527ab073ab
2 changed files with 32 additions and 18 deletions
@@ -0,0 +1,27 @@
<?php
/**
* @param array $file
* @return string
*/
function ZipFileHandler(array $file){
$gameFileName = $file['gameFile']['name'];//Game name
$gameFileTmp = $file['gameFile']['tmp_name'];//Tmp location of the file
$gameFileError = $file['gameFile']['error'];//File error
$fileExtGame = explode('.', $gameFileName);
$fileActualExtGame = strtolower(end($fileExtGame));
$allowedFileTypeGame = array('zip');
if((in_array($fileActualExtGame,$allowedFileTypeGame))&&($gameFileError === 0)){
$gameFileNewName = uniqid("", true). "." . $fileActualExtGame;
if(empty($gameFileName)){
header("location: ../../../Frontend/index.php?error=emptyFile");
exit();
}
rename($gameFileTmp,"../../Games/".$gameFileNewName);
return $gameFileNewName;
}
}