path issues and os translation

master
Stephen Kerr 1 year ago
parent 2f06200f11
commit 1adac60073

@ -6,7 +6,7 @@ from flask import render_template
import glob
import os
UPLOAD_FOLDER = './static/img/'
UPLOAD_FOLDER = ".\static\img\\"
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}
def allowed_file(filename):
return '.' in filename and \
@ -36,14 +36,18 @@ from flask import request
def upload_file():
if request.method == 'POST':
file = request.files['tile']
# print(request.files["zine test.png"])
if file and allowed_file(file.filename):
filename = file.filename
print("zine test.png",filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
overwrite = request.form["overwrite"]
os.system(f"cp ./static/img/{ filename } ./static/img/{ overwrite }")
os.system(f"rm ./static/img/{ filename }")
if file and allowed_file(file.filename):
filename, fileextension = os.path.splitext(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], (overwrite + fileextension) ))
# print("==============================================================")
# print(fileextension)
# print(f"copy { UPLOAD_FOLDER + file.filename} { UPLOAD_FOLDER + overwrite + fileextension }")
# os.system(f"copy { UPLOAD_FOLDER + file.filename} { UPLOAD_FOLDER + overwrite + fileextension }")
# print(f"del { UPLOAD_FOLDER + file.filename }")
# os.system(f"del { UPLOAD_FOLDER + file.filename }")
return redirect("/")
# f = request.files['the_file']

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

@ -18,7 +18,7 @@
<body>
{% for image in images %}<img src="{{ image }}">{% endfor %}
<form action="/breadcube/overlap/upload/" method="POST" enctype="multipart/form-data">
<form action="/upload/" method="POST" enctype="multipart/form-data">
<label for="tile">Choose an image to upload:</label>
<input type="file"
id="tile" name="tile" required>

Loading…
Cancel
Save