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

165
Visualizações
The image from the form does not load

I am creating a website for each node.js/express. I made a form and it works well. However, when you add the line "enctype = "composite/form data", everything stops working (instead of the values of the input fields, "Avoid" is added to the database).

Handlebars:

    <form action="/target/" method="POST" enctype="multipart/form-data">
      <label for="name">Имя:</label>
        <input name="name"><br><br>
      <label for="age">Возраст:</label>
        <input name="age"><br><br>
      <label for="comm">Комментарий:</label>
      <input name="salary"><br><br>
      <label for="img">Картинка:</label>
      <input type="file" name="f">
        <input type="submit">
</form>

Node:

mongoClient.connect(async function(error, mongo) {
    if (!error) {
        let db = mongo.db('NODE_db');
        let coll = db.collection('users');
app.post('/target/', urlencodedParser, async function(req, res) {
            //Validation
            if (req.body.name == '' || req.body.age == '' || req.body.comm == ''){
                res.status(400).json({mess: "fill fields"})
            }
            else {
                await coll.insertOne(req.body);
                res.redirect('/')
            }
        });
} else {
    console.error(error);
}
});
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