Replace path "\" with "/" server-side

This commit is contained in:
valadaptive
2023-12-05 17:55:52 -05:00
parent 795ca2247b
commit 39d771cc4a
5 changed files with 7 additions and 6 deletions

View File

@@ -1588,7 +1588,8 @@ app.post('/uploadimage', jsonParser, async (request, response) => {
const imageBuffer = Buffer.from(base64Data, 'base64');
await fs.promises.writeFile(pathToNewFile, imageBuffer);
// send the path to the image, relative to the client folder, which means removing the first folder from the path which is 'public'
pathToNewFile = pathToNewFile.split(path.sep).slice(1).join(path.sep);
// Use forward slashes, even on Windows
pathToNewFile = pathToNewFile.split(path.sep).slice(1).join('/');
response.send({ path: pathToNewFile });
} catch (error) {
console.log(error);