This is a Razor Pages example of a service to upload files or images
Based on the YouTube video below by Sameer Saini
File Upload In Asp.net Core - How To Save A File In C# and ASP.NET Core Razor Pages
- Services.IImageUploadService.cs
- Services.ImageUploadService.cs
- Index.cshtml
- A folder in wwwroot called images
You also need to register this service in program.cs
builder.Services.AddRazorPages();
builder.Services.AddScoped<IImageUploadService, ImageUploadService>();