i'm beginner in asp.net framework, but i really encouraged to learn and apply it. https://docs.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start
i followed it and everything is ok and i passed to add new models, tables.
suppose we have the Movie model which is :
public class Movie
{
public int ID { get; set; }
public string Title { get; set; }
public DateTime ReleaseDate { get; set; }
public string Genre { get; set; }
public decimal Price { get; set; }
}
and below is the code of Create process:
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
_context.Movie.Add(Movie);
await _context.SaveChangesAsync();
return RedirectToPage("./Index");
}
Below is a section from the from :
<div class="form-group">
<label asp-for="Movie.Price" class="control-label"></label>
<input asp-for="Movie.Price" class="form-control" />
<span asp-validation-for="Movie.Price" class="text-danger"></span>
</div>
Now i want to add a new field to the form to upload the "Cover image", so the user can browse and select the cover image for the movie to upload it in the same form.
my questions are :
i think to store the file name in the DB, so each movie has a column "CoverImage", then i can use it to display or delete. is this good approach ?
what is the best place to store the files ? in "wwwroot" or another folder or doesn't matter ?
what is the best or latest method to upload the image ? what should i add in the three sections of codes above? i did a search and i found many approaches and methods, but i need to know from you as experts in asp.net what is the best approach.