How to pass upload files to MVC action

4 posts, 0 answers
  1. Tomaz
    Tomaz avatar
    10 posts
    Member since:
    May 2012

    Posted 09 Sep 2012 Link to this post

    Hi,

    I use Ajax.BeginForm to add new article. How can I pass uploaded files together with Save action
    to save new Article firts and after that save files into database?
    I use 
    @(Html.Kendo().Upload()
                .Name("file")
                )
    inside form.

    Thx
    Tomaz
  2. Just
    Just avatar
    24 posts
    Member since:
    Aug 2012

    Posted 05 Oct 2012 Link to this post

    Try this:
    public ActionResult UploadFiles(IEnumerable<HttpPostedFileBase> attachments)
  3. Adam
    Adam avatar
    3 posts
    Member since:
    May 2012

    Posted 12 Nov 2012 Link to this post

    You can also do it this way:

    HttpPostedFileBase file = Request.Files[0];
  4. Tomaz
    Tomaz avatar
    10 posts
    Member since:
    May 2012

    Posted 13 Nov 2012 Link to this post

    I found out that its not working with Ajax form so I changed to @Html.BeginForm and its work if Upload has same name than action parameter.

Back to Top