AMBER HB HABIB

AMBER HB HABIB

  • 1.1k
  • 612
  • 485

file upload in mvc

May 28 2024 9:14 AM

 I have a project with file upload and its is working fine i am using simple <form method="post" enctype="multipart/form-data" asp-controller="Home" asp-action="UploadFile">
        <input type="file" name="postedFile" />
       
        <input type="submit" id="btnUpload" value="Upload" />
    </form>
    <form method="post" asp-controller="Home" asp-action="DownloadFile">
        <input type="hidden" id="hfFileId" name="FileId" />
        <input type="submit" id="btnDownload" value="Download" style="display:none" />
    </form>
    <hr />
Now I want to add dropdown for chosing documnet type like legal or normal so  i add last column in my model
 

  public class FileModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string ContentType { get; set; }
        public byte[] Data { get; set; }

        public string doctype{ get; set; }
    }
but when i tried to code razor view like this it is not allowed it did not recognize doctype remember my model in view is @addTagHelper*, Microsoft.AspNetCore.Mvc.TagHelpers
@model IEnumerable<TestCoreAppTest.Models.FileModel>

@Html.DropDownListFor(model => model.doctype, listItems, "-- Select Status --")

Answers (4)