fix
This commit is contained in:
@@ -21,18 +21,20 @@ const createbrand = [
|
||||
title, link, description,
|
||||
}
|
||||
|
||||
if (req.files?.image) {
|
||||
const image = req.files.image
|
||||
if (req.files?.logo) {
|
||||
const image = req.files.logo
|
||||
const fileName = 'brands' + Date.now() + '.' + image.name
|
||||
const acceptableFormats = ['png', 'jpg', 'jpeg', 'webp']
|
||||
if (!acceptableFormats.includes(image.mimetype.split('/')[1]))
|
||||
return res.status(422).json({ validation: { image: { msg: _faSr.format.image } } })
|
||||
return res.status(422).json({ validation: { logo: { msg: _faSr.format.image } } })
|
||||
if (image.size / 1024 > maxAttachmentSize)
|
||||
return res
|
||||
.status(422)
|
||||
.json({ validation: { image: { msg: `حجم تصویر نباید بیشتر از ${maxAttachmentSize} KB باشد.` } } })
|
||||
data.image = fileName
|
||||
.json({ validation: { logo: { msg: `حجم تصویر نباید بیشتر از ${maxAttachmentSize} KB باشد.` } } })
|
||||
data.logo = fileName
|
||||
await image.mv(`./static/uploads/images/brands/${fileName}`)
|
||||
}else{
|
||||
res.status(422).json({ validation: { logo: { msg: `تصویر را ارسال کنید` } } })
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user