hopefully last fix

This commit is contained in:
Martin Quarda 2024-10-07 07:49:12 +02:00
parent f2614ab9af
commit 357537b6d2

View File

@ -63,10 +63,11 @@ class Main extends Component {
let form = document.getElementById("form"); let form = document.getElementById("form");
let api_endpoint = form.action; let api_endpoint = form.action;
let formData = new FormData(form); let formData = new FormData(form);
console.log(this.state.files) if (this.state.files && api_endpoint == "/api/upload_files"){
this.state.files.forEach((file, _)=>{ this.state.files.forEach((file, _)=>{
formData.append(file.name, file); formData.append(file.name, file);
}) })
}
fetch(addr_prefix + api_endpoint, { fetch(addr_prefix + api_endpoint, {
method:"POST", method:"POST",
body: formData, body: formData,
@ -153,7 +154,7 @@ class Main extends Component {
{this.state.page == "#upload_files" && {this.state.page == "#upload_files" &&
<div> <div>
<form id="form" action="/api/upload_files" class="container" onSubmit={(e) => this.onSubmit(e)}> <form id="form" action="/api/upload_files" class="container" onSubmit={(e) => this.onSubmit(e)}>
<label>Zvolte soubory <input type="file" accept=".jpg,.png,.webp,.webm,.avi,.mkv,.mp4" multiple="true" onChange={(e)=> this.handleChangeFiles(e)}/></label> <label>Zvolte soubory <input type="file" accept=".jpg,.png,.webp,.webm,.avi,.mkv,.mp4" multiple="true" onChange={(e)=> this.handleChangeFiles(e).bind(this)}/></label>
<button type="submit" class="btn btn-primary">Nahrát</button> <button type="submit" class="btn btn-primary">Nahrát</button>
</form> </form>
</div>} </div>}
@ -276,7 +277,7 @@ class Main extends Component {
<p>Sportem ku chlastu!</p> <p>Sportem ku chlastu!</p>
</div> </div>
<div class="col-xl-6"> <div class="col-xl-6">
<h1 class="text" >Výsledky 1. ročníku</h1> <h1 class="text">Výsledky 1. ročníku</h1>
{this.state.results && {this.state.results &&
<table class="table results"> <table class="table results">
<thead> <thead>