upload form zdaj prinese FileStorage objekt

master
Kostanjevec 2022-06-05 21:18:24 +02:00
parent d07c5c2597
commit f8bae1331a
2 changed files with 16 additions and 5 deletions

View File

@ -10,7 +10,7 @@
{% block content %}
</body>
<form method="post" enctype="multipart/form-data" action="localhost:5000/upload/uploader">
<form id="form" method="post" enctype="multipart/form-data" action="/upload/uploader">
<div class="drop-zone">
<span class="drop-zone__prompt">Drop file here or click to upload</span>
<input type="file" name="file" class="drop-zone__input">
@ -42,6 +42,8 @@
if (e.dataTransfer.files.length) {
inputElement.files = e.dataTransfer.files;
console.log("oddajam form", e);
document.getElementById("form").submit();
}
dropZoneElement.classList.remove("drop-zone--over");

View File

@ -1,3 +1,4 @@
from email import message
from flask import (
Blueprint, flash, g, redirect, render_template, request, session, url_for
)
@ -16,6 +17,11 @@ engine = create_engine(CONFIG['DB_CONNECTION'])
dbsessionmaker = sessionmaker(bind=engine)
dbsession = dbsessionmaker()
nc = nextcloud_client.Client('https://obzorje.kompot.si')
nc.login('gia', 'gia0000!')
@bp.route("/", methods=("GET", "POST"))
def index():
return render_template("menu/upload.html")
@ -24,16 +30,19 @@ def index():
@bp.route('/uploader', methods = ['GET', 'POST'])
def upload_file():
print("heyy")
message = ""
if request.method == 'POST':
#flask gets the file
upload = request.files["file"]
print("hello")
upload = request.files #???
#upload to nc
#nc.put_file('testdir/remotefile.txt', 'localfile.txt') #not sure kako bi to
#get public link
#link = nc.share_file_with_link('testdir/remotefile.txt')
#update db
#predpostavlja title, ir, owner_id, item_location
#card = Card(title=name, interest_rate=-1.0, owner_id=1, item_location=public_link)
#card = Card(title=name, interest_rate=-1.0, owner_id=1, item_location=link, )
#dbsession.add(card)
#dbsession.commit()
return render_template("menu/upload.html", message=message)