This commit is contained in:
payacom
2026-10-09 15:44:47 +03:30
parent 367416d419
commit e5dcd0f1b2
14 changed files with 282 additions and 197 deletions

View File

@@ -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)