in asp.net-mvc, is there a good library or pattern to follow when saving users content (images, files, etc)

前端 未结 4 1823
眼角桃花
眼角桃花 2020-12-08 23:29

i have an admin section of my website where \"authors\" can upload files like pictures for photo galleries, etc to include in dynamic content sections of my website later.

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-09 00:15

    If you create a form with an enctype of multipart/form-data then you can receive an HttpPostedFileBase in your Controller.

    In the view:

    In the Controller:

    public ActionResult MyAction(HttpPostedFileBase httpPostedFileBase) { // Your code here. }

    The httpPostedFileBase argument will get mapped by the default model binder.

提交回复
热议问题