upload file

This commit is contained in:
Jacob Søfeldt 2021-04-29 11:47:55 +02:00
parent 87830d0a9e
commit 2b08ef3e07
3 changed files with 202 additions and 0 deletions

View File

@ -267,6 +267,86 @@
</div> </div>
</div> </div>
</section> </section>
<section>
<form>
<div class="row">
<div class="col">
<div class="mb-3">
<label for="List1" class="form-label">GameJam</label>
<input
class="form-control"
list="datalistOptions"
id="List1"
placeholder="Type to search..."
/>
<datalist id="datalistOptions">
<option value="text"></option>
</datalist>
</div>
</div>
<div class="col">
<div class="mb-3">
<label for="Text1" class="form-label">Title</label>
<input type="text" class="form-control" id="Text1" required />
</div>
</div>
</div>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="Switch1" />
<label class="form-check-label" for="Switch1"
>Er det et web spille?</label
>
</div>
<div class="row">
<div class="col">
<div class="mb-3">
<div>
<label for="formFile1" class="form-label">Game file</label>
<input
class="form-control form-control-sm"
type="file"
id="formFile1"
accept=".zip"
required
/>
</div>
<div class="mb-3 pt-2">
<label for="formFile2" class="form-label"
>Thumbnail file</label
>
<input
class="form-control form-control-sm"
type="file"
id="formFile2"
aria-describedby="fileHelp"
accept="image/*"
/>
<div id="fileHelp" class="form-text">
Thumbnail is optional.
</div>
</div>
</div>
</div>
<div class="col">
<div class="mb-3">
<label for="Text2" class="form-label">Description</label>
<textarea
class="form-control"
id="Text2"
rows="3"
required
></textarea>
</div>
</div>
</div>
<div class="col-12 d-flex justify-content-end">
<button type="submit" class="btn btn-primary btn-lg">
Submit
</button>
</div>
</form>
</section>
</div> </div>
</div> </div>
</body> </body>

View File

@ -1073,6 +1073,98 @@
kommentar omkring hvad spillet handler om, for at give spilleren den kommentar omkring hvad spillet handler om, for at give spilleren den
bedste oplevelse. bedste oplevelse.
</p> </p>
<section class="text-start">
<form id="uploadFile" method="POST">
<div class="row">
<div class="col">
<div class="mb-3">
<label for="List1" class="form-label">GameJam</label>
<input
class="form-control"
list="datalistOptions"
id="List1"
placeholder="Type to search..."
/>
<datalist id="datalistOptions">
<option value="text"></option>
</datalist>
</div>
</div>
<div class="col">
<div class="mb-3">
<label for="Text1" class="form-label">Title</label>
<input
type="text"
class="form-control"
id="Text1"
required
/>
</div>
</div>
</div>
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="Switch1" />
<label class="form-check-label" for="Switch1"
>Er det et web spille?</label
>
</div>
<div class="row">
<div class="col">
<div class="mb-3">
<div>
<label for="formFile1" class="form-label"
>Game file</label
>
<input
class="form-control form-control-sm"
type="file"
id="formFile1"
accept=".zip"
required
/>
</div>
<div class="mb-3 pt-2">
<label for="formFile2" class="form-label"
>Thumbnail file</label
>
<input
class="form-control form-control-sm"
type="file"
id="formFile2"
aria-describedby="fileHelp"
accept="image/*"
/>
<div id="fileHelp" class="form-text">
Thumbnail is optional.
</div>
</div>
</div>
</div>
<div class="col">
<div class="mb-3">
<label for="Text2" class="form-label">Description</label>
<textarea
class="form-control"
id="Text2"
rows="3"
required
></textarea>
</div>
</div>
</div>
<div class="col-12 d-flex justify-content-end">
<button
type="submit"
class="btn btn-primary btn-lg"
id="indsend1"
value="Indsend"
>
Submit
</button>
</div>
</form>
</section>
</section> </section>
<!-- Upload filer slut --> <!-- Upload filer slut -->
@ -1263,6 +1355,7 @@
<script src="Javascript/Kalender.js"></script> <script src="Javascript/Kalender.js"></script>
<script src="Javascript/SpinningWheel.js"></script> <script src="Javascript/SpinningWheel.js"></script>
<script src="Javascript/LoginFunctionality.js"></script> <script src="Javascript/LoginFunctionality.js"></script>
<script src="Javascript/UplodeFiles.js"></script>
<!-- Body scripts end --> <!-- Body scripts end -->
</body> </body>
</html> </html>

View File

@ -0,0 +1,29 @@
$(document).ready(function () {
axios.defaults.baseURL = "http://localhost/Game-Jaming";
$("#uploadFile").submit(function (e) {
let URL = "/Backend/Controllers/FileHandler/upload.php";
const params = new URLSearchParams();
params.append("submitUpload", document.getElementById("indsend1").value);
params.append(
"gameJamId",
document.getElementById("datalistOptions").value
);
params.append("gameTitle", document.getElementById("Text1").value);
params.append("description", document.getElementById("Text2").value);
params.append("gameFile", document.getElementById("formFile1").value);
params.append("thumbnailFile", document.getElementById("formFile2").value);
params.append("isWebBased", document.getElementById("Switch1").checked);
axios
.post(URL, params)
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
e.preventDefault();
});
});