Fix image uploading if character name contains a dot
This commit is contained in:
parent
c4cae9d00f
commit
7acd2916ec
|
@ -970,7 +970,7 @@ export async function saveBase64AsFile(base64Data, characterName, filename = '',
|
|||
const requestBody = {
|
||||
image: dataURL,
|
||||
ch_name: characterName,
|
||||
filename: filename,
|
||||
filename: String(filename).replace(/\./g, '_'),
|
||||
};
|
||||
|
||||
// Send the data URL to your backend using fetch
|
||||
|
|
|
@ -384,9 +384,9 @@ app.post('/uploadimage', jsonParser, async (request, response) => {
|
|||
}
|
||||
|
||||
// if character is defined, save to a sub folder for that character
|
||||
let pathToNewFile = path.join(DIRECTORIES.userImages, filename);
|
||||
let pathToNewFile = path.join(DIRECTORIES.userImages, sanitize(filename));
|
||||
if (request.body.ch_name) {
|
||||
pathToNewFile = path.join(DIRECTORIES.userImages, request.body.ch_name, filename);
|
||||
pathToNewFile = path.join(DIRECTORIES.userImages, sanitize(request.body.ch_name), sanitize(filename));
|
||||
}
|
||||
|
||||
ensureDirectoryExistence(pathToNewFile);
|
||||
|
|
Loading…
Reference in New Issue