This is a migrated thread and some comments may be shown as answers.

How to pass upload files to MVC action

3 Answers 205 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Tomaz
Top achievements
Rank 1
Tomaz asked on 09 Sep 2012, 03:56 PM
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

3 Answers, 1 is accepted

Sort by
0
Just
Top achievements
Rank 1
answered on 05 Oct 2012, 10:02 PM
Try this:
public ActionResult UploadFiles(IEnumerable<HttpPostedFileBase> attachments)
0
Adam
Top achievements
Rank 1
answered on 13 Nov 2012, 12:04 AM
You can also do it this way:

HttpPostedFileBase file = Request.Files[0];
0
Tomaz
Top achievements
Rank 1
answered on 13 Nov 2012, 05:35 PM
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.

Tags
Upload
Asked by
Tomaz
Top achievements
Rank 1
Answers by
Just
Top achievements
Rank 1
Adam
Top achievements
Rank 1
Tomaz
Top achievements
Rank 1
Share this question
or