I m working on a webapp project that using Flask framework .in this app the admin is able to store ,edit and delete an image file from the dataset
I used the code bellow to build the edit process
@app.route("/word/edit/<int:id>", methods=["GET", "POST"])
def edit(id):
pos = Word.query.get_or_404(id)
if request.method == 'POST':
meaning = request.form['meaning']
image = request.files['image']
db.session.commit()
return redirect('/adminpanel')
else:
return render_template("edit.html", post=pos)
and here is the code of edit.html
<form method="post" action="/word/edit/{{ post.id }}" enctype="multipart/form-data">
<dl>
<p>
<input type="text" name='meaning' value="{{ post.meaning }}" required>
</p>
</dl>
<dl>
<p>
<input type="file" name='image' value="/download/{{post.meaning}}" required>
</p>
</dl>
<p>
<input type="submit" value="Upload">
</p>
</form>
when I m redirected to edit.html I find the correct value in the meaning input but the is no file in the image inpute how can I solve this ,please