While attempting to upload a file and normalize its name, I encountered an issue with IE11 not supporting the 'normalize' method. After some research, I discovered the 'unorm' polyfill which resolved the normalization problem. However, I faced another hurdle as IE11 does not support the 'File' constructor. As a workaround, I utilized 'Blob' instead, but encountered the issue of the filename showing as 'blob' on the server side.
Code for other browsers:
var fileName = file.name.normalize('NFD').replace(/[\u0300-\u036f]/g, "");
var newFile = new File([file], fileName, { type: file.type });
newFile.label = 'FICHIER';
Code for IE11:
fileName = unorm.nfd(file.name);
newFile = new Blob([file], { type: file.type });
newFile.label = 'Fichier';
newFile.name= fileName;
For sending the request to the server, I am using formdata:
fd = new FormData();
fd.append("id", param);
fd.append(file.label || "uploadedFile", file, file[paramName]);
If you have any suggestions on how to retrieve the filename or if there is an alternative approach to tackle this issue, please let me know.