new fille handler
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user