From f2614ab9af9d4cfa8e20a4be70661dd126032aca Mon Sep 17 00:00:00 2001 From: Martin Quarda Date: Mon, 7 Oct 2024 07:39:54 +0200 Subject: [PATCH] fix of uploading files --- alkatorapi/views.py | 2 +- frontend/src/scripts/index.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/alkatorapi/views.py b/alkatorapi/views.py index 2cd2490..76836cf 100644 --- a/alkatorapi/views.py +++ b/alkatorapi/views.py @@ -205,7 +205,7 @@ def upload_files(request): with open(random_name, "wb+") as destination: for chunk in f.chunks(): destination.write(chunk) - return HttpResponse('{"success":"Úspěšně nahráno! Počkejte až dojde ke schválení nahraných souborů.}', content_type='application/json') + return HttpResponse('{"success":"Úspěšně nahráno! Počkejte až dojde ke schválení nahraných souborů."}', content_type='application/json') @staff_member_required diff --git a/frontend/src/scripts/index.js b/frontend/src/scripts/index.js index 94058fc..11b6837 100644 --- a/frontend/src/scripts/index.js +++ b/frontend/src/scripts/index.js @@ -55,7 +55,7 @@ class Main extends Component { onHashChange(event){ this.setState({page: window.location.hash}) } - handleChange(event) { + handleChangeFiles(event) { this.setState({files: [...event.target.files]}) } onSubmit(event){ @@ -63,10 +63,10 @@ class Main extends Component { let form = document.getElementById("form"); let api_endpoint = form.action; let formData = new FormData(form); + console.log(this.state.files) this.state.files.forEach((file, _)=>{ - formData.append(`${file.name}`, file); + formData.append(file.name, file); }) - formData fetch(addr_prefix + api_endpoint, { method:"POST", body: formData,