flask with a project in my project I'm uploading an application I'm developing. I have 2 image upload areas. I don't have any trouble when I load 2. 400 Bad Request: KeyError: I get an error in the 'gelinFoto' style when I upload an image or when I push the send button when I never load it. Where am I making a mistake?
def admin(): form = KisiForm(request.form) if request.method == "POST": gelinFoto = request.files['gelinFoto'] damatFoto = request.files['damatFoto'] if gelinFoto or damatFoto: yol = app.config['UPLOAD_FOLDER'] + whuser yol = yol + '/profil' gfilename = secure_filename(gelinFoto.filename) dfilename = secure_filename(damatFoto.filename) gelinFoto.save(os.path.join(yol, gfilename)) damatFoto.save(os.path.join(yol, dfilename)) kisi = bilgi(gelinFoto = gfilename, damatFoto = dfilename) db.session.add(kisi) db.session.commit() return redirect(url_for("admin")) return render_template("admin/index.html",form=form) Html
<form method="post" enctype="multipart/form-data" class="col-12"> <div class="form-group"> <label for="exampleFormControlFile1">Gelinin Fotoğrafı : </label> <div class="upload"> <img src="{{ url_for('static', filename='admin/images/upload.png') }}" class="uploadImage" alt="">{{ render_field(form.gelinFoto,id="gelinFoto",class="gdfoto",accept=".png,.jpg,.jpeg") }} </div> <small id="emailHelp" class="form-text text-muted">Gelinin fotoğrafını yükleyiniz.</small> </div> <div class="form-group"> <label for="exampleFormControlFile1">Damatın Fotoğrafı : </label> <div class="upload"><img src="{{ url_for('static', filename='admin/images/upload.png') }}" class="uploadImage" alt="">{{ render_field(form.damatFoto,id="damatFoto",class="gdfoto",accept=".png,.jpg,.jpeg") }} </div> <small id="emailHelp" class="form-text text-muted">Damatın fotoğrafını yükleyiniz.</small>