0

I am trying to send 6 based64 images with some other data but I keep getting error entity is too large even I have added below code in my app.js file

 `app.use(bodyparser.json({ limit: '50mb', extended: true }))

app.use(bodyparser.urlencoded({ limit: "50mb", extended: true, parameterLimit: 50000 }))`

If I try with the postman then there is no error only with web application.

I am using Angular as Front-end.

I don't know why this error is occurring.

Kindly your help would be great.

Thanks in Advance.

K.S
  • 297
  • 2
  • 22

1 Answers1

0
const express = require('express');
const bodyParser = require('body-parser')
const multer = require('multer')
var fs = require('fs');
var storage = multer.diskStorage({
        destination: function (req, file, callback) {
                callback(null, './public');
        },
        filename: function (req, file, callback) {
                callback(null, file.fieldname + '-' + Date.now() + '.png');
        }
});

var upload = multer({ storage: storage });

const app = express();

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))

app.use(express.static('public'))
app.post('/', upload.single('file'), (req, res) => {
        console.log(req.body.key1);
        fs.readFile(req.file.path, function (err, data) {
                res.writeHead(200, { 'Content-Type': 'text/html' });
                res.write(data);
                res.end();
        });
})
app.listen(3000);
  • Hi, I am able to submit images using this way but I have 6 images with the specific name like `Aimg`, `Bimg` `Cimg` etc. so when return the path then how I will send the path of relevant image – K.S Dec 07 '19 at 09:15
  • because from return array how I will identify which image is of which parms – K.S Dec 07 '19 at 09:16