images fix
This commit is contained in:
parent
66eefe37a5
commit
c880cbf48c
|
@ -2,6 +2,8 @@
|
||||||
require_once "../../../bootstrap.php";
|
require_once "../../../bootstrap.php";
|
||||||
use Backend\Models\GameData;
|
use Backend\Models\GameData;
|
||||||
|
|
||||||
|
$isImages = false;
|
||||||
|
|
||||||
if(isset($_POST['submitUpload'])){
|
if(isset($_POST['submitUpload'])){
|
||||||
//Get the data from the user form
|
//Get the data from the user form
|
||||||
$gameFile = $_FILES['gameFile'];
|
$gameFile = $_FILES['gameFile'];
|
||||||
|
@ -34,21 +36,30 @@ if(isset($_POST['submitUpload'])){
|
||||||
if(in_array($fileActualExtGame,$allowedFileTypeGame) || in_array($thumbnailFileName,$allowedFileTypeThumbnail)){
|
if(in_array($fileActualExtGame,$allowedFileTypeGame) || in_array($thumbnailFileName,$allowedFileTypeThumbnail)){
|
||||||
if($gameFileError === 0 || $thumbnailFileError === 0){
|
if($gameFileError === 0 || $thumbnailFileError === 0){
|
||||||
$gameFileNewName = uniqid("", true). "." . $fileActualExtGame;
|
$gameFileNewName = uniqid("", true). "." . $fileActualExtGame;
|
||||||
|
|
||||||
|
if(!empty($thumbnailFileName)){
|
||||||
$thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb;
|
$thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb;
|
||||||
|
$isImages = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(empty($gameFileName)){
|
if(empty($gameFileName)){
|
||||||
header("location: ../../../Frontend/index.php?error=emptyFile");
|
header("location: ../../../Frontend/index.php?error=emptyFile");
|
||||||
exit();
|
exit();
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$gameData = new GameData();
|
$gameData = new GameData();
|
||||||
$gameData->game_name = $title;
|
$gameData->game_name = $title;
|
||||||
$gameData->game_link = $gameFileNewName;
|
$gameData->game_link = $gameFileNewName;
|
||||||
$gameData->description = $desc;
|
$gameData->description = $desc;
|
||||||
$gameData->img = $thumbnailFileNewName;
|
if($isImages) $gameData->img = $thumbnailFileNewName;
|
||||||
$gameData->is_web_Based = $isWebBased;
|
$gameData->is_web_Based = $isWebBased;
|
||||||
$gameData->save();
|
$gameData->save();
|
||||||
|
|
||||||
rename($gameFileTmp,"../../Games/".$gameFileNewName);
|
rename($gameFileTmp,"../../Games/".$gameFileNewName);
|
||||||
rename($thumbnailFileTmp,"../../../Frontend/images/".$fileActualExtThumb);
|
if($isImages){
|
||||||
|
rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
echo "Der var en fejl med at uploade din file";
|
echo "Der var en fejl med at uploade din file";
|
||||||
|
|
Loading…
Reference in New Issue