mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-30 16:14:04 +08:00
Updated image drop handling to respect original file name
Now uses the previously timestamp gen name as a backup to the original name. Aligns with the image manager upload which uses the original name where given. Closes #3470
This commit is contained in:
parent
3f271ebecb
commit
3fe666f36a
@ -60,13 +60,7 @@ async function uploadImageFile(file, pageId) {
|
|||||||
throw new Error(`Not an image file`);
|
throw new Error(`Not an image file`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let ext = 'png';
|
const remoteFilename = file.name || `image-${Date.now()}.png`;
|
||||||
if (file.name) {
|
|
||||||
let fileNameMatches = file.name.match(/\.(.+)$/);
|
|
||||||
if (fileNameMatches.length > 1) ext = fileNameMatches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
const remoteFilename = "image-" + Date.now() + "." + ext;
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file, remoteFilename);
|
formData.append('file', file, remoteFilename);
|
||||||
formData.append('uploaded_to', pageId);
|
formData.append('uploaded_to', pageId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user