How can i pass a File to an HTTP form in Flask?

22 Views Asked by At

I want to pass an instance of an object to a HTTP form to be modified, including a file field.

I try with this:

...

form = AnnuncioForm()
form.descrizione.data = annuncio_db['descrizione']
file = open('./images/default.jpg', 'rb')
form.immagine1.data = FileStorage(file)

...

return render_template('modifica_annuncio.html', id=id, form=form)

If i try to print print(form.immagine1.data), it print a FileStorage object but in the site it doesn't appear:

enter image description here

0

There are 0 best solutions below