Hi
I have this Razor page with the uploader control.
The preloaded files are in the structure
List<UploaderUploadedFiles> uploaderFiles = new List<UploaderUploadedFiles>();
And I want to show the file extension in the uploader control as well.
This works with the Type attribute in "fileInfo".
But if I want to delete a file, I get in "args" always the filename with two times the extension. e.g. P1000256.JPG.JPG. Of course then also in the controller.
This problem only occurs when I have "preloaded files".
Here the code example for it.
Thanks for the support.
@{
string[] fileNames = Directory.GetFiles(supportDetail.UploadDirectory);
List<UploaderUploadedFiles> uploaderFiles = new List<UploaderUploadedFiles>();
foreach (string fileName in fileNames)
{
FileInfo fileInfo = new FileInfo(fileName);
uploaderFiles.Add(new UploaderUploadedFiles
{
Name = fileInfo.Name,
Size = fileInfo.Length,
Type = fileInfo.Extension
// Show extension in Control
});
}
var asyncSettings = new Syncfusion.EJ2.Inputs.UploaderAsyncSettings { SaveUrl = @Url.Content($"~/{lang}/upload/save"), RemoveUrl = @Url.Content($"~/{lang}/upload/remove"), ChunkSize = 10000000 };
}
<ejs-uploader id="UploadFiles"
allowedExtensions=".pdf,.txt,.jpg"
autoUpload="true"
files="@uploaderFiles"
locale="@langFull"
asyncSettings="@asyncSettings"
removing="onFileRemove">
</ejs-uploader>
<script type="text/javascript">
function onFileRemove(args) {
debugger;
<-------------
args.filesData[0].name = "P1000256.JPG.JPG"
<-------------
let uploadpath = encodeURIComponent(document.querySelector('#UploadDirectory').value);
args.customFormData = [{ 'pathname': uploadpath }];
args.postRawFile = false;
}
</script>
Hi Reto Ruemmeli,
Thank you for reaching out to us. Based on the shared information, we have tried to reproduce the issue. Unfortunately, we were unable to find any issues when preloading the file with a double extension. Kindly check out the shared sample.
To proceed with addressing this issue effectively, we kindly request the following information from you:
Regards,
Yohapuja S
Thanks for this interesting information!
You're welcome, Nick
Hi
i found the error, then name for the preloaded Files must be without Extension.
Many thanks for your help.
Regards, Reto
foreach (string fileName in fileNames)
{
FileInfo fileInfo = new FileInfo(fileName);
uploaderFiles.Add(new UploaderUploadedFiles
{
Name = System.IO.Path.GetFileNameWithoutExtension(fileInfo.Name),
Size = fileInfo.Length,
Type = fileInfo.Extension
});
}
Glad to know your issue has been resolved. Please get back to us for assistance in the future.