You can now upload zip filer
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?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 = $_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: ./index.php?error=emptyFile");
|
||||
exit();
|
||||
}else{
|
||||
$gameData = new GameData();
|
||||
$gameData->game_name = $title;
|
||||
$gameData->game_link = $gameFileNewName;
|
||||
$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";
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -6,7 +6,7 @@ require "../bootstrap.php";
|
||||
|
||||
|
||||
$gameJam = GameJam::firstOrCreate([
|
||||
'name' => "First game jam ever!", 'startTime' => "2021-03-03T12:40", 'endTime' => "2021-04-03T12:40", 'description' => "Det her et en beskrivelse"
|
||||
'name' => "First game jam ever!", 'start_time' => "2021-03-03T12:40", 'end_time' => "2021-04-03T12:40", 'description' => "Det her et en beskrivelse"
|
||||
]);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ $gameJam = GameJam::firstOrCreate([
|
||||
<title>HTML Tutorial</title>
|
||||
<body>
|
||||
|
||||
<form action="SigningUp.php" method="POST">
|
||||
<form action="Controllers/User/SigningUp.php" method="POST">
|
||||
<input type="text" name="groupName" placeholder="Group name">
|
||||
<input type="number" name="groupAmount" placeholder="Group Amount">
|
||||
<input type="number" name="gameJamId" placeholder="Game Jam id">
|
||||
@@ -26,7 +26,7 @@ $gameJam = GameJam::firstOrCreate([
|
||||
</form>
|
||||
|
||||
|
||||
<form action="Login.php" method="POST">
|
||||
<form action="Controllers/User/Login.php" method="POST">
|
||||
<input type="text" name="groupName" placeholder="Group name">
|
||||
<input type="password" name="password" placeholder="password">
|
||||
<input type="submit" name="login" value="login">
|
||||
|
||||
@@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
|
||||
class GameData extends Eloquent
|
||||
{
|
||||
protected $fillable = [
|
||||
'game_link', 'is_web_Based', "img"
|
||||
'game_name', 'game_link', 'is_web_Based', "img"
|
||||
];
|
||||
|
||||
public function group(){
|
||||
|
||||
Reference in New Issue
Block a user