mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix image uploading if character name contains a dot
This commit is contained in:
@ -970,7 +970,7 @@ export async function saveBase64AsFile(base64Data, characterName, filename = '',
|
|||||||
const requestBody = {
|
const requestBody = {
|
||||||
image: dataURL,
|
image: dataURL,
|
||||||
ch_name: characterName,
|
ch_name: characterName,
|
||||||
filename: filename,
|
filename: String(filename).replace(/\./g, '_'),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Send the data URL to your backend using fetch
|
// 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
|
// 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) {
|
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);
|
ensureDirectoryExistence(pathToNewFile);
|
||||||
|
Reference in New Issue
Block a user