diff --git a/server.js b/server.js index 54a27c308..c04edc630 100644 --- a/server.js +++ b/server.js @@ -2680,8 +2680,12 @@ app.post('/uploadimage', jsonParser, async (request, response) => { }); app.get('/listimgfiles/:folder', (req, res) => { - const directoryPath = path.join(__dirname, 'public/user/images/', req.params.folder); - console.log(directoryPath); + const directoryPath = path.join(process.cwd(), 'public/user/images/', req.params.folder); + + if (!fs.existsSync(directoryPath)) { + fs.mkdirSync(directoryPath, { recursive: true }); + } + fs.readdir(directoryPath, (err, files) => { if (err) { return res.status(500).send({ error: "Unable to retrieve files" });