Sunday 7 February 2021

Part 23: Image upload for ProductDetails Controller

#5 minutes of reading In article 22, I have shown you CRUD operation of product details (mobile details) but as we know ecommerce site also have image of product which we didn’t covered in 22. Let’s implement image upload here in this article.
Image should be uploaded from create view of productDetails but in our model there is not property for storing image. Let’s add property in ProductDetails model.
Add migration and update database commands from package manager console.
  Create view model for Product Details.
  Add Create view from ProductDetailsVM class shown below.
Update ProductDetails controller class and inject IWebHostEnvironment for accessing wwwRoot folder path.
  Update Create action method of ProductDetails controller for image upload functionality.
Update create view of ProductDetails controller with below piece of code
Update index view highlighted below.
Run application and check browser window.
Open Index view of ProductDetails controller and above created records shown in Index view highlighted below.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home