diff --git a/alkatorapi/views.py b/alkatorapi/views.py index 76836cf..bc7e0f6 100644 --- a/alkatorapi/views.py +++ b/alkatorapi/views.py @@ -203,7 +203,7 @@ def upload_files(request): rand = random.randint(9999999999999) random_name = f'photos/uploads/{rand}.jpg' with open(random_name, "wb+") as destination: - for chunk in f.chunks(): + for chunk in file.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') diff --git a/frontend/src/scripts/index.js b/frontend/src/scripts/index.js index bcb8a5d..e5f4ac4 100644 --- a/frontend/src/scripts/index.js +++ b/frontend/src/scripts/index.js @@ -63,11 +63,6 @@ class Main extends Component { let form = document.getElementById("form"); let api_endpoint = form.action; let formData = new FormData(form); - if (this.state.files && api_endpoint == "/api/upload_files"){ - this.state.files.forEach((file, _)=>{ - formData.append(file.name, file); - }) - } fetch(addr_prefix + api_endpoint, { method:"POST", body: formData, @@ -151,10 +146,10 @@ class Main extends Component {
{this.state.text}
} - {this.state.page == "#upload_files" && + {this.state.page == "#upload_files" &&
this.onSubmit(e)}> - +
}