diff --git a/remote/src/routes/files.js b/remote/src/routes/files.js index 39eb517..5c0af9f 100644 --- a/remote/src/routes/files.js +++ b/remote/src/routes/files.js @@ -29,14 +29,15 @@ router.post('/upload', upload.single('file'), (req, res) => { const filename = req.file.originalname; let targetDir; + if (remotePath) { - targetDir = path.join(fileService.uploadDir, remotePath); + if (remotePath.match(/^[A-Z]:\\?$/i)) { + targetDir = remotePath; + } else { + targetDir = remotePath; + } } else { - targetDir = fileService.uploadDir; - } - - if (!targetDir.startsWith(fileService.uploadDir)) { - return res.status(403).json({ error: 'Invalid path' }); + targetDir = 'C:\\'; } if (!fs.existsSync(targetDir)) {