0

I would like to upload an image and then display that image directly in the same page, under the "Choose file" button, same as shown in the attached picture:

example

I found a solution for Java, which is described here

For Flask, I had a look at other threads, for example:

python flask display image on a html page

How to serve static files in Flask

However, they are not exactly what I am looking for. I also found a similar question, which has not been answered yet:

Upload an Image and Display it back as a response using Flask

My main idea is having a form with input type of file:

<form method=POST enctype=multipart/form-data>
    <input id="my-file-selector" type="file" name="input_img">
</form>

After uploading the image, it will be displayed directly under the upload button. Does anybody know how to do it with Python Flask?

2
  • If you want to preview the image before uploading Here. If you want to upload to server first Here Commented Dec 11, 2019 at 18:42
  • @kudeh I would like to upload it to the server, but the second link you sent is not what I am looking for. In that thread, the image is uploaded to another the html page ('/register'), not in the same html page, where the upload button is located Commented Dec 11, 2019 at 19:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.