You can now upload zip filer
This commit is contained in:
parent
9ab0526608
commit
b242918038
|
@ -107,3 +107,4 @@ fabric.properties
|
|||
composer.phar
|
||||
/vendor/
|
||||
/Backend/Database/test.db
|
||||
/Backend/Games/
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
||||
}
|
|
@ -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(){
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
|
||||
|
||||
<form action="../Backend/upload.php" method="POST" id="uploadGame" enctype="multipart/form-data">
|
||||
<form action="../Backend/Controllers/upload.php" method="POST" id="uploadGame" enctype="multipart/form-data">
|
||||
|
||||
<input type="text" name="gameTitle" placeholder="Title på spillet"><br><br>
|
||||
|
||||
|
@ -26,9 +26,6 @@
|
|||
<label for="uploadGame">Upload spil [.zip]</label>
|
||||
<input type="file" name="gameFile" placeholder="Upload dit spil"><br><br>
|
||||
|
||||
<label for="uploadGame">Upload thumbnail[png,jpg,gif]</label>
|
||||
<input type="file" name="thumbnailFile" placeholder="Upload en thumbnail"><br><br>
|
||||
|
||||
<label for="web">Er spillet web based</label>
|
||||
<input type="checkbox" id="web" name="isWebBased" value="true"><br><br>
|
||||
|
||||
|
|
31
upload.php
31
upload.php
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
if(isset($_POST['submitUpload'])){
|
||||
//Get the data from the user form
|
||||
$gameFile = $_FILES['gameFile'];
|
||||
$thumbnailFile = $_FILES['thumbnailFile'];
|
||||
$desc = $_POST['description'];
|
||||
|
||||
|
||||
|
||||
//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
|
||||
|
||||
//Handel data for thumbnail
|
||||
$gameFileName = $_FILES['thumbnailFile']['name'];//Thumbnail name
|
||||
$gameFileTmp = $_FILES['thumbnailFile']['tmp_name'];//Tmp location of the file
|
||||
$gameFileType =$_FILES['thumbnailFile']['type'];//File type
|
||||
|
||||
|
||||
|
||||
$fileExt = explode('.', $gameFileName);
|
||||
$fileActualExt = strtolower(end($fileExt));
|
||||
|
||||
|
||||
$fileDestination = '../images/';
|
||||
|
||||
move_uploaded_file($gameFileTmp,$fileDestination );
|
||||
|
||||
}
|
Loading…
Reference in New Issue