fix of uploading files
This commit is contained in:
parent
86e97dd55a
commit
f2614ab9af
@ -205,7 +205,7 @@ def upload_files(request):
|
|||||||
with open(random_name, "wb+") as destination:
|
with open(random_name, "wb+") as destination:
|
||||||
for chunk in f.chunks():
|
for chunk in f.chunks():
|
||||||
destination.write(chunk)
|
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
|
@staff_member_required
|
||||||
|
@ -55,7 +55,7 @@ class Main extends Component {
|
|||||||
onHashChange(event){
|
onHashChange(event){
|
||||||
this.setState({page: window.location.hash})
|
this.setState({page: window.location.hash})
|
||||||
}
|
}
|
||||||
handleChange(event) {
|
handleChangeFiles(event) {
|
||||||
this.setState({files: [...event.target.files]})
|
this.setState({files: [...event.target.files]})
|
||||||
}
|
}
|
||||||
onSubmit(event){
|
onSubmit(event){
|
||||||
@ -63,10 +63,10 @@ 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)
|
||||||
this.state.files.forEach((file, _)=>{
|
this.state.files.forEach((file, _)=>{
|
||||||
formData.append(`${file.name}`, file);
|
formData.append(file.name, file);
|
||||||
})
|
})
|
||||||
formData
|
|
||||||
fetch(addr_prefix + api_endpoint, {
|
fetch(addr_prefix + api_endpoint, {
|
||||||
method:"POST",
|
method:"POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user