DEV Community

danaharley
danaharley

Posted on

[ASK] cancel updating the image if there is a validation error at node js

I have a controller and a model like this.

const update = async (req, res, next) => { try { const payload = req.body if (req.file) { const tmp_path = req.file.path; const originalExt = req.file.originalname.split(".")[ req.file.originalname.split(".").length - 1 ]; const filename = req.file.filename + "." + originalExt; const target_path =

Top comments (0)