I have a form like this
<form id="imageForm" method="post" action="/printDDT">
<img name=imageFile src={{DDTimage}} width="50%" height="50%">
<br/><br/>
<button type="submit">Print DDT</button>
</form>
and I want to read the src
in my post function in app.py
I tried this
@app.route("/printDDT", methods=["GET", "POST"])
def printDDT():
if request.method == "POST":
imageFile = request.files.get('imageFile')
print(secure_filename[imageFile.filename])
fileList = updateFile()
DDTimage = os.path.join(app.config['JPG_FOLDER'], 'ddt.jpg')
return render_template('home.html', fileList=fileList, DDTimage=DDTimage)
but I got
File "app.py", line 73, in printDDT
print(secure_filename[imageFile.filename])
AttributeError: 'NoneType' object has no attribute 'filename'
What am I doing wrong?
Edit: In the end I followe this strategy How to get the value of a variable within an html tag in flask
Maybe not the cleanest solution but definitely the smartest.