Commit b84bd210 authored by Chris's avatar Chris Committed by enahum

more robust file upload extension (#7390)

parent 9ed1d956
......@@ -296,8 +296,16 @@ class FileUpload extends React.Component {
min = String(d.getMinutes());
}
const ext = file.name.lastIndexOf('.');
const name = formatMessage(holders.pasted) + d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + hour + '-' + min + (ext >= 0 ? file.name.substr(ext) : '');
var ext = '';
if (file.name) {
if (file.name.includes('.')) {
ext = file.name.substr(file.name.lastIndexOf('.'));
}
} else if (items[i].type.includes('/')) {
ext = '.' + items[i].type.split('/')[1].toLowerCase();
}
const name = formatMessage(holders.pasted) + d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + hour + '-' + min + ext;
const request = uploadFile(
file,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment