reels
This commit is contained in:
@@ -74,7 +74,7 @@ const addUserMessageToTicket = async (req, res) => {
|
||||
|
||||
const { ticketId } = req.query
|
||||
const { text } = req.body
|
||||
const { file } = req.files
|
||||
const file = req.file
|
||||
let fileUrl = null
|
||||
if (file) {
|
||||
// اگر فایل ارسال شده است، آن را ذخیره کنید
|
||||
@@ -83,8 +83,8 @@ const addUserMessageToTicket = async (req, res) => {
|
||||
fs.mkdirSync(uploadDir, { recursive: true })
|
||||
}
|
||||
|
||||
// اسمِ فایل هیچوقت مستقیم از ورودیِ کاربر (file.name) گرفته نمیشه — فقط پسوندش
|
||||
const uniqueFileName = `${Date.now()}-${crypto.randomUUID()}${path.extname(file.name || '')}`
|
||||
// اسمِ فایل هیچوقت مستقیم از ورودیِ کاربر (file.originalname) گرفته نمیشه — فقط پسوندش
|
||||
const uniqueFileName = `${Date.now()}-${crypto.randomUUID()}${path.extname(file.originalname || '')}`
|
||||
const filePath = path.join(uploadDir, uniqueFileName)
|
||||
await fs.move(file.path, filePath)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user