From 48fd2f5463b76ba49609a0753326d45ada08d57e Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Mon, 9 Mar 2026 20:11:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(remote):=20=E4=B8=8A=E4=BC=A0=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E5=86=99=E5=85=A5=E7=94=A8=E6=88=B7=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E7=9A=84=E7=9B=AE=E5=BD=95=E8=80=8C=E9=9D=9Euploads=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- remote/src/routes/files.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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)) {