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

315
Vistas
how to show the response on page?
...

index.html


    <body>
        <h1>upload test</h1>

        <!--<form method="post" enctype="multipart/form-data" action="/picture"> -->
        <form id="pictureForm" method="post" enctype="multipart/form-data">
         <div>
           <label for="file">Choose file to upload</label>
           <input type="file" name="file" id="pictureFile"  multiple>
         </div>
         <div>
           <button>Submit</button>
         </div>
        </form>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <script src="./upload.js"></script>
    </body>
...

upload.js

...
    await axios({
        method: 'post',
        url: '/upload',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data',
        },
    })
...


server.js

...
app.get('/', async (req, res, next) => {
    try {
        res.writeHead(200, { 'Content-Type': 'text/html' });
        const data = await fs.readFile('../index.html')
        res.write('Hello nodejs');
        res.end(data);
        next();
    }
    catch (err) {
        console.error(err);
    }
});

app.post('/upload', upload.single('file'), async (req, res, next) => {
    try {
        res.send('work');   <-- not working
    }
});
...

i'm making image upload server. and i success. i can upload image into particular directory that i want.

problem is, i want to see the phrase 'success' using res.end()(or res.send, etc). but web page was not change!

enter image description here

correctly, web got the response. but i don't know how to show this response on page.

please teach me.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

On the frontend you can do something like this

fetch("http://localhost:5500/upload", requestOptions).then(response => response.text())
about 4 years ago · Juan Pablo Isaza Denunciar
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