Solution 1 :

Solved, form needed to be

  <form name="Recon" action="{{url_for('recon')}}" method = "POST" enctype="multipart/form-data">
    <input type="file" id="filechooser" name="image" accept="image/*" capture="environment">
    <input type="submit" value = "Rec">
  </form>

Problem :

I have the following form

  <form name="Recon" action="{{url_for('recon')}}" method = "POST">
    <input type="file" id="myFace" name="image" accept="image/*" capture="environment">
    <input type="submit" value = "Rec">
  </form>

However, I find myself not knowing how to store the image on the computer, and flask’s request.files[“image”] does not work, since request.files is empty. The line request.forms[“image”] returns the string with the name of the image.

Here’s the code where I call upon it

@app.route('/recon', methods = ['POST', 'GET'])
def recon():
    #cod = id(url)
    dir = 'database/'
    if request.method=='POST':
        pic = request.files["image"]
        pic.save(os.path.join(dir, "chk.png"))
    res = id(pc = True)
    if not res:
        return render_template('feito.html')
    else:
        return render_template('recon.html', pc = pic)

How would you do this?
Please and thank you.

PS: Before you ask, secure_filename does not work because of the current version of requests that I use for Tensorflow.

Comments

Comment posted by cizario

just give your answer a green tick.

By