mirror of
https://github.com/StefBuwalda/WebTech.git
synced 2025-10-30 11:19:58 +00:00
Fixed? Idek
This commit is contained in:
17
application/utils.py
Normal file
17
application/utils.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from werkzeug.utils import secure_filename
|
||||
import os
|
||||
from application import app
|
||||
from flask_login import current_user # type: ignore
|
||||
|
||||
|
||||
def saveImage(image: ...):
|
||||
filename = secure_filename(image.filename)
|
||||
save_path = os.path.join(
|
||||
app.config["UPLOAD_FOLDER"], # type: ignore
|
||||
str(current_user.id),
|
||||
filename,
|
||||
)
|
||||
os.makedirs(os.path.dirname(save_path), exist_ok=True)
|
||||
image.save(save_path) # type: ignore
|
||||
filename2 = str(current_user.id) + "/" + filename
|
||||
return filename2
|
||||
Reference in New Issue
Block a user