Fixed som stuff
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
require_once "../../../bootstrap.php";
|
||||
use Backend\Models\GameData;
|
||||
|
||||
|
||||
if(isset($_POST['submitUpload'])){
|
||||
//Get the data from the user form
|
||||
$gameFile = $_FILES['gameFile'];
|
||||
$desc = $_POST['description'];
|
||||
$title = $_POST['gameTitle'];
|
||||
$isWebBased = isset( $_POST['isWebBased']);
|
||||
|
||||
|
||||
//Handle data for game files
|
||||
$gameFileName = $_FILES['gameFile']['name'];//Game name
|
||||
$gameFileTmp = $_FILES['gameFile']['tmp_name'];//Tmp location of the file
|
||||
$gameFileType =$_FILES['gameFile']['type'];//File type
|
||||
$gameFileError =$_FILES['gameFile']['error'];//File error
|
||||
|
||||
|
||||
$fileExt = explode('.', $gameFileName);
|
||||
$fileActualExt = strtolower(end($fileExt));
|
||||
|
||||
|
||||
$allowedFileType = array('zip');
|
||||
|
||||
if(in_array($fileActualExt,$allowedFileType)){
|
||||
if($gameFileError === 0){
|
||||
$gameFileNewName = uniqid("", true). "." . $fileActualExt;
|
||||
if(empty($gameFileName)){
|
||||
header("location: ../../../Frontend/index.php?error=emptyFile");
|
||||
exit();
|
||||
}else{
|
||||
$gameData = new GameData();
|
||||
|
||||
$gameData->game_name = $title;
|
||||
$gameData->game_link = $gameFileNewName;
|
||||
$gameData->description = $desc;
|
||||
$gameData->is_web_Based = $isWebBased;
|
||||
$gameData->save();
|
||||
|
||||
rename($gameFileTmp,"../../Games/".$gameFileNewName);
|
||||
}
|
||||
}else{
|
||||
echo "Der var en fejl med at uploade din file";
|
||||
}
|
||||
}else{
|
||||
echo "Wrong file type";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user