upload form zdaj prinese FileStorage objekt
parent
d07c5c2597
commit
f8bae1331a
|
@ -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");
|
||||
|
|
17
upload.py
17
upload.py
|
@ -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)
|
Loading…
Reference in New Issue