27 lines
837 B
PHP
27 lines
837 B
PHP
|
<?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;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|