Get filename when uploading file

This is the blaozr server I am practicing on.

What I want is to bring the file name value in the number 1 mark to the input box in number 2.


this is my code source.






2 Replies

SP Sureshkumar P Syncfusion Team March 1, 2023 10:57 AM UTC

Hi Slow,

You can achieve your requirement by using the below code example.

Find the code example here:

<span>FileName textbox </span>

<SfTextBox @bind-Value="@FileName"></SfTextBox>

<br/>

<br />

<span>uploader component </span>

<SfUploader AutoUpload="false" >

    <UploaderEvents ValueChange="OnChange" ></UploaderEvents>

</SfUploader>

 

@code {

 

    public string FileName { get; set; } = "";

 

    private void OnChange(UploadChangeEventArgs args)

    {

        foreach (var file in args.Files)

        {

            this.FileName = file.FileInfo.Name;

            var path = @"path" + file.FileInfo.Name;

            FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);

            file.Stream.WriteTo(filestream);

            filestream.Close();

            file.Stream.Close();

        }

    }

}


Regards,
Sureshkumar P



SM slow MS March 2, 2023 02:13 AM UTC

I already solved this problem.

But thank you so much for your answer.


Loader.
Up arrow icon