fix(remote): 上传直接写入用户选择的目录而非uploads文件夹
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user