S
S
saiasasd2022-04-21 09:45:37
Node.js
saiasasd, 2022-04-21 09:45:37

How to send accepted file using formData?

Hello. Found the express-formidable library. It takes a file, saves it to the Temp folder.
Firstly, I would like to know how to save the received file in the server directory (there is no information about this even in the official documentation)
Secondly, please tell me how you can send this file to another server (another server accepts FormData)
Here my server:

const express = require('express');
const formidable = require('express-formidable');

const PORT = 8000;

const app = express();

app.use(express.urlencoded({extended: false}));
app.use(formidable());

app.listen(PORT, () =>{
    console.log(`Server works on port ${PORT}`);
});

app.get('/', (req, res) =>{
    res.send('server works, PORT is ' + PORT);
});

app.post('/upload', (req, res) => {
    res.send(req.files);

});


Here is the request I am making and what the server is getting
6260fd8610aa4184448597.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question