How to get details of the selected files in the file uploader control?

Hi,

I have a File uploader control that takes the document file. On the upload button click instead of using saveurl and uploadurl, i need to call a custom function where i need to get the file information and its stream.  I see ValueChange event that gives both file information and stream data but it is not triggering. And tried another event FileSelected which is triggering but can't receive file details including stream. How to get file details including stream of selected files in the file uploader control

                    <SfUploader @ref="UploadObj" ID="UploadFiles" AllowedExtensions=".doc, .docx, .pdf" AutoUpload="false">
                        <UploaderEvents FileSelected="OnFileSelected" ValueChange="OnChangeUpload"></UploaderEvents>
                    </SfUploader>
                    <SfButton @onclick="UploadClicked">
                        Upload
                    </SfButton>

        public void OnChangeUpload(UploadChangeEventArgs args)
        {
                if (args != null && args?.Files?.Count > 0)
                {
                    FilesToUpload = new List<UploadFiles>();
                    FilesToUpload = args.Files.ToList();
                    StatusMessage = "File Names: " + string.Join(", ", args.Files.Select(result => result.FileInfo?.Name));
                }
            }
        }

3 Replies 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team November 12, 2020 11:21 AM UTC

Hi Richy, 


Greetings from Syncfusion support. 


We checked the reported requirement. We would like to inform you that, we can get the stream in the change event by calling the upload method in button click. Refer to the below code, 


<SfUploader @ref="UploadObj" ID="UploadFiles" AllowedExtensions=".doc, .docx, .pdf" AutoUpload="false"> 
    <UploaderEvents ValueChange="OnChangeUpload"></UploaderEvents> 
</SfUploader> 
<SfButton @onclick="UploadClicked"> 
    Upload 
</SfButton> 
 
@code { 
 
    SfUploader UploadObj; 
 
 
    public void UploadClicked() 
    { 
        UploadObj.Upload(); 
    } 
 
    private void OnChangeUpload(UploadChangeEventArgs args) 
    { 
        foreach (var file in args.Files) 
        { 
            var path = @"path" + file.FileInfo.Name; 
            FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write); 
            file.Stream.WriteTo(filestream); 
            filestream.Close(); 
            file.Stream.Close(); 
        } 
    } 
} 
   

Please find the sample below, 




Please check the sample and get back to us if you need further assistance. 


Regards, 
Sevvandhi N 



Marked as answer

RI Richy November 25, 2020 05:23 AM UTC


Getting status text. How to remove the text that showing status like "Ready to upload" and "File upload successfully".


SN Sevvandhi Nagulan Syncfusion Team November 26, 2020 03:13 PM UTC

Hi Richy, 


You can hide the status message by using below css code. 


<style> 
    .e-upload .e-upload-files .e-upload-file-list .e-file-container .e-file-status { 
        display: none 
    } 
</style> 

Please find the sample below, 





Regards, 
Sevvandhi N 


Loader.
Up arrow icon