working files?
This commit is contained in:
parent
50bc8a2034
commit
b0b5449ddb
@ -203,7 +203,7 @@ def upload_files(request):
|
|||||||
rand = random.randint(9999999999999)
|
rand = random.randint(9999999999999)
|
||||||
random_name = f'photos/uploads/{rand}.jpg'
|
random_name = f'photos/uploads/{rand}.jpg'
|
||||||
with open(random_name, "wb+") as destination:
|
with open(random_name, "wb+") as destination:
|
||||||
for chunk in f.chunks():
|
for chunk in file.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')
|
||||||
|
|
||||||
|
@ -63,11 +63,6 @@ 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);
|
||||||
if (this.state.files && api_endpoint == "/api/upload_files"){
|
|
||||||
this.state.files.forEach((file, _)=>{
|
|
||||||
formData.append(file.name, file);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
fetch(addr_prefix + api_endpoint, {
|
fetch(addr_prefix + api_endpoint, {
|
||||||
method:"POST",
|
method:"POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
@ -154,7 +149,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" name="files" accept=".jpg,.png,.webp,.webm,.avi,.mkv,.mp4" multiple="true" onChange={(e)=> this.handleChangeFiles.bind(this)(e)}/></label>
|
<label>Zvolte soubory <input type="file" name="files" accept=".jpg,.png,.webp,.webm,.avi,.mkv,.mp4" multiple={true} onChange={(e)=> this.handleChangeFiles.bind(this)(e)}/></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>}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user