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

181
Views
save image path in MySQL with express?

I am using express and multer to upload images. If I send the image to the intended folder but it does not save the path and it shows the error:

Cannot POST /api/imagen
const db = require("../models");
const multer = require("multer");
const path = require("path");
const Imagen = db.imagens;

let nameImage = "";
const storage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, path.join(__dirname, "/uploads"));
},
filename: (req, file, cb) => {
const ext = file.originalname.split(".").pop();
nameImage = `${Date.now()}.${ext}`;
cb(null, nameImage);
},
});

const upload = multer({ storage });

(exports.create = upload.single("url")),
async (req, res) => {
try {
const data = await Imagen.create({
    titulo: req.body.titulo,
    url: nameImage,
});
res.send({
  mesagge: "Imágen cargada!",
});
} catch (error) {
  res.send(error);
}
};

enter image description here

about 4 years ago · Santiago Gelvez
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!