made upload file

This commit is contained in:
neerholt 2021-03-08 13:01:47 +01:00
parent 913fdae646
commit 69db0c3d78
2 changed files with 53 additions and 0 deletions

View File

@ -13,6 +13,28 @@
<input type="submit" name="submitKeyWord" value="Submit">
</form>
<hr>
<form action="../Backend/upload.php" method="POST" id="uploadGame" enctype="multipart/form-data">
<input type="text" name="gameTitle" placeholder="Title på spillet"><br><br>
<input type="text" name="description" placeholder="Beskrivelse"><br><br>
<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>
<input type="submit" name="submitUpload" value="Submit">
</form>
</body>
</html>

31
upload.php Normal file
View File

@ -0,0 +1,31 @@
<?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 );
}