Skip to main content

Posts

Featured

File Upload in Blazor Server ASP.NET Core 5.0

This blog going to explain how to upload the file in Blazor server. The InputFile file component helps to upload the file in Blazor. The following is a razor page code. Here, the InputFile component is added to read the browser file into .NET code. It will render the <input type="file" > HTML element. In the code the InputFile component will call the UploadFile method on the change event. The InputFileChangeEventArgs help to access the file. In the UploadFile method the FileStream will create a file on specific path. Index.razor @page "/" @using System.IO @using Microsoft.AspNetCore.Hosting @inject IWebHostEnvironment Environment <InputFile OnChange= "@UploadFile" /> @if (ImgUrl != null ) { <div> <img src= "@ImgUrl" style= "width:100px" /> </div> } @code{ private string ImgUrl; private async Task UploadFile(InputFileChangeEventArgs e) {

Latest Posts

Cross-Origin Requests (CORS) in ASP.NET Core Web API

Local Storage in Blazor using Blazored

JavaScript Interoperability in Blazor

Entity Framework Core (EF) with SQL Server LocalDB

SignalR with JavaScript in ASP.NET Core MVC

View-Based Authorization in ASP.NET Core

Policy-Based Authorization in ASP.NET Core

Startup Class in ASP.NET Core

In-Memory Cache in ASP.NET Core

ASP.NET Core Web API Documentation with Swagger

Role-Based Authorization in ASP.NET Core MVC