Fixed error on images file ext

This commit is contained in:
neerholt
2021-03-10 09:46:22 +01:00
parent 527ab073ab
commit 053bf845cf
2 changed files with 42 additions and 45 deletions
@@ -1,19 +1,16 @@
<?php
/**
* @param array $file
* @param string $gameFileName
* @param string $gameFileTmp
* @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
function ZipFileHandler(string $gameFileName, string $gameFileTmp){
$fileExtGame = explode('.', $gameFileName);
$fileActualExtGame = strtolower(end($fileExtGame));
$allowedFileTypeGame = array('zip');
if((in_array($fileActualExtGame,$allowedFileTypeGame))&&($gameFileError === 0)){
if(in_array($fileActualExtGame,$allowedFileTypeGame)){
$gameFileNewName = uniqid("", true). "." . $fileActualExtGame;
if(empty($gameFileName)){
header("location: ../../../Frontend/index.php?error=emptyFile");
@@ -22,6 +19,29 @@ function ZipFileHandler(array $file){
rename($gameFileTmp,"../../Games/".$gameFileNewName);
return $gameFileNewName;
}
return NULL;
}
/**
* @param string $thumbnailFileName
* @param string $thumbnailFileTmp
* @return string
*/
function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp){
$fileExtThumb = explode('.', $thumbnailFileName);
$fileActualExtThumb = strtolower(end($fileExtThumb));
$allowedFileTypeThumbnail = array('gif', 'jpeg', 'png', 'svg');
if(in_array($fileActualExtThumb,$allowedFileTypeThumbnail)){
$thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb;
if(empty($thumbnailFileName)){
header("location: ../../../Frontend/index.php?error=emptyFile");
exit();
}
rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName);
return $thumbnailFileNewName;
}
return NULL;
}