WASM File Upload not working anymore

Hi Syncfusion Team and fellow Devs,

for some reason the File Upload stopped working in one of my Apps as i moved to .NET 6, so I created a new Blazor WASM (hosted) App and tried to rebuild it from scratch, according to your documentation.

https://blazor.syncfusion.com/documentation/file-upload/getting-started

Here are the steps:

  1. Create Blazor WASM App (ASP.NET Core hosted)
  2. Installed Nuget Package Syncfusion.Blazor.Inputs (Latest Stable 19.3.0.47)
  3. Added Syncfusion to Program.cs
  4. builder.Services.AddSyncfusionBlazor();
  5. Added Bootstrap Reference to index.html
  6. <link rel='nofollow' href="_content/Syncfusion.Blazor.Themes/bootstrap4.css" rel="stylesheet" />
  7. Added Package to _Imports.razor --> @using Syncfusion.Blazor.Inputs
  8. As I don't want to use a server-side API for my File Uploads, I added the following Code to Index.razor

@using System.IO

<SfUploader AutoUpload="false">
    <UploaderEvents ValueChange="OnChange"></UploaderEvents>
</SfUploader>


@code {

    private void OnChange(UploadChangeEventArgs args)
    {
        foreach (var file in args.Files)
        {
            var path = @"D:\" + file.FileInfo.Name;
            FileStream filestream = new FileStream(path, FileMode.Create, FileAccess.Write);
            file.Stream.WriteTo(filestream);
            filestream.Close();
            file.Stream.Close();
        }
    }
}

Uploader says the file is successfully uploaded but the File never gets created. Am I missing something here?


3 Replies

DR Deepak Ramakrishnan Syncfusion Team November 3, 2021 11:48 AM UTC

Hi Thomas, 
  
Greetings from syncfusion support. 
  
We are currently working on your requirement. We will update the further details in two business days.(9th November 2021). 
  
Thanks, 
Deepak R. 



DA Daniel November 6, 2021 07:52 AM UTC

Hi Syncfusion Support,

oh boy, that was a mistake of mine. I switched from Blazor Server to WASM. That's why this can't work. Nevertheless, after creating a Controller according to the documentation the Count of IList<IFormFile> UploadFiles was always 0. I managed to get the files with this:

var files = Request.Form.Files;

Anyways, thank you and you can close this Thread.



DR Deepak Ramakrishnan Syncfusion Team November 8, 2021 06:30 AM UTC

Hi Thomas, 
 
Thanks for your update. 
 
We are glad that your requirement has fulfilled also  we thank you for sharing us your solution . We are always happy to assist you if you need any further assistance. 
 
Thanks, 
Deepak R. 
 


Loader.
Up arrow icon