Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda