Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/rentals.picotech.app/public_html/server/middleware/ drwxr-xr-x |
Viewing file: Select action/file-type: import multer from 'multer'; import path from 'path'; import fs from 'fs'; import { v4 as uuidv4 } from 'uuid'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // Ensure upload directory exists const uploadDir = path.join(__dirname, '../../uploads'); if (!fs.existsSync(uploadDir)) { fs.mkdirSync(uploadDir, { recursive: true }); } const storage = multer.diskStorage({ destination: (req, file, cb) => { const subDir = req.params.type || 'documents'; const fullPath = path.join(uploadDir, subDir); if (!fs.existsSync(fullPath)) { fs.mkdirSync(fullPath, { recursive: true }); } cb(null, fullPath); }, filename: (req, file, cb) => { const uniqueName = `${uuidv4()}-${Date.now()}${path.extname(file.originalname)}`; cb(null, uniqueName); } }); const fileFilter = (req, file, cb) => { const allowedTypes = /jpeg|jpg|png|gif|pdf|doc|docx/; const extname = allowedTypes.test(path.extname(file.originalname).toLowerCase()); const mimetype = allowedTypes.test(file.mimetype); if (mimetype && extname) { return cb(null, true); } else { cb(new Error('Only images and documents are allowed')); } }; const upload = multer({ storage, limits: { fileSize: parseInt(process.env.MAX_FILE_SIZE) || 5 * 1024 * 1024 // 5MB }, fileFilter }); export default upload; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0037 ]-- |