Double File-extension with preloaded Files in Uploader Control

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>

5 Replies

YS Yohapuja Selvakumaran Syncfusion Team August 18, 2023 12:58 PM UTC

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:

  1. Modified Sample: If possible, could you modify the shared sample to demonstrate the issue? This will enable us to have a clearer understanding of the problem and assist you better.
  2. Issue Description: Please provide more details about the specific problem you are facing when preloading a file with a double extension. Any additional context or error messages you encounter would be beneficial.
  3. Visual Documentation: If feasible, sharing a screenshot or even a video demonstration of the issue would greatly assist us in comprehending the problem and providing accurate solutions.


Regards,

Yohapuja S



Attachment: SyncfusionCoreUploader_preupload_37b66ad9.zip


NI Nick August 20, 2023 04:30 PM UTC

Thanks for this interesting information!



PR Padmini Ramamurthy Syncfusion Team August 21, 2023 05:57 AM UTC

You're welcome, Nick



RR Reto Ruemmeli August 21, 2023 08:44 AM UTC

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


               });

   }



SS Shereen Shajahan Syncfusion Team August 23, 2023 04:47 AM UTC

Glad to know your issue has been resolved. Please get back to us for assistance in the future.


Loader.
Up arrow icon