fix(remote): 上传直接写入用户选择的目录而非uploads文件夹

This commit is contained in:
2026-03-09 20:11:56 +08:00
parent 88f265757c
commit 48fd2f5463

View File

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