Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
during form submission in Nodejs when I submit details of an product except the image all details are present in the terminal
  1. When I add product details with image(form) .The image detail is not coming in the terminal

    I have written the code as:
    
    var createError = require('http-errors');
    Var express = require('express');
    var path = require('path');
    var cookieParser = require('cookie-parser');
    var logger = require('morgan');
    
    var userRouter = require('./routes/user');
    var adminRouter = require('./routes/admin');
    var hbs=require('express-handlebars');
    
    var app = express();
    **Var Fileupload=require('express-Fileupload');**
    
    
    // view engine setup
    app.set('views', path.join(__dirname, 'views'));
    app.set('view engine', 'hbs');
    app.engine('hbs',hbs.engine({extname:'hbs',defaultLayout:'layout',layoutsDir:__dirname+'/views/layout/',partialsDir:__dirname+'/views/partials/'}));
    
    app.use(logger('dev'));
    app.use(express.json());
    app.use(express.urlencoded({ extended: false }));
    app.use(cookieParser());
    app.use(express.static(path.join(__dirname, 'public')));
    **app.use(fileupload());**
    app.use('/', userRouter);
    app.use('/admin', adminRouter);
    
    // catch 404 and forward to error handler
    app.use(function(req, res, next) {
      next(createError(404));
    });
    
    // error handler
    app.use(function(err, req, res, next) {
      // set locals, only providing error in development
      res.locals.message = err.message;
      res.locals.error = req.app.get('env') === 'development' ? err : {};
    
      // render the error page
      res.status(err.status || 500);
      res.render('error');
    });
    
    module.exports = app;
    
    
    
    
    
    
        AND ALSO USED:
    
        *router.get('/add-product',function(req,res){
          res.render('admin/add-product')
    
    
        })
        Router.Post('/add-product',(Req,res)=>{
          console.log(req.body);
          console.log(req.files.image);
        })
        module.exports = router;*
    

THIS IS THE CODE THAT I HAD ASSIGNED IT IS NOT WORKING IT SHOWS: { name: 'sega', category: 'boot', description: 'this is an excellent stabiliyu prhwdh wdjwdd' } POST /admin/add-product 500 24.735 ms - 3589

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!