Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
Retrieving File Name of Image Not Working with multipart/form-data

I've made a page that allows users to upload a file with HTML input tags:

<p><input type="file" accept="image/*" name="itemimg" id="itemimg" onchange="loadFile(event)" required></p>

The page uses enctype multipart/form-data at the top of the form since it uses a POST request to retrieve a file.

<form action="/sell" method="post" enctype='multipart/form-data'>

The problem is that I am able to add the image to a directory in the folder using requestfiles, but am not able to retrieve the name of the image (for example: "image.jpg") using imgsrc = request.form.get("itemimg") and store into an SQLITE3 database. When using request.form, the system simply retrieves null.

 f = request.files['itemimg']
        f.save(os.path.join(
            app.config['UPLOAD_FOLDER'], secure_filename(f.filename)))

However, when I remove enctype multipart/form-data from the input at the top of my HTML file, I am able to store the name of the file "image.jpg" into the database using request.form but unable to download the file into my directory.

Is there a workaround so that I am able to store the file in the directory AND add it to the database using the request.form?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda