I working on asp.net core 5 mvc web application , I face issue I can't store Picture User on database table [dbo].[AspNetUsers].
so can you tell me how to store personal picture of user on table [dbo].[AspNetUsers].
I already add new column PictureUser on table [dbo].[AspNetUsers] to store User Picture .
I need to know what I will modify on controller and view to store user picture on database table .
I working on Microsoft identity membership when register user
my model as
public class RegisterVM { public string EmailAddress { get; set; } public string Password { get; set; } public byte[] PictureUser { get; set; } }
my action controller
public async Task<IActionResult> Register(RegisterVM registerVM) { var newUser = new ApplicationUser() { FullName = registerVM.FullName, Email = registerVM.EmailAddress, UserName = registerVM.EmailAddress, //How to add Image upload Here }; var newUserResponse = await _userManager.CreateAsync(newUser, registerVM.Password); if (newUserResponse.Succeeded) { await _signInManager.SignInAsync(newUser, isPersistent: false); return View("RegisterCompleted"); } return View(registerVM); }
on view
@model RegisterVM; <form asp-action="Register"> <div asp-validation-summary="ModelOnly" class="text-danger"></div> <div class="form-group"> <label asp-for="EmailAddress" class="control-label"></label> <input asp-for="EmailAddress" class="form-control" /> <span asp-validation-for="EmailAddress" class="text-danger"></span> </div> <div class="form-group"> <label asp-for="Password" class="control-label"></label> <input asp-for="Password" class="form-control" /> <span asp-validation-for="Password" class="text-danger"></span> </div> //How to add Image upload Here <div class="form-group"> <input class="btn btn-outline-success float-right" type="submit" value="Sign up" /> </div> </form>
How to add Image Upload on View And Controller Action this is Exactly my Question ?