File upload in asp.net mvc using ajax
Posted
by Maxim
on Stack Overflow
See other posts from Stack Overflow
or by Maxim
Published on 2010-04-16T14:30:23Z
Indexed on
2010/04/16
14:33 UTC
Read the original article
Hit count: 338
Hello!
i have a simple html form with two controls: input-text and input-file i need to write an ajax query (using jquery is better) to send data (file and value from text field to mvc acton)
i wrote
$.ajax({
type: "POST",
url: "/controller/acton",
enctype: 'multipart/form-data',
data: 'text=' + $("#text").val() + '&file=' + $("#file").val()
...
and in controller:
[HttpPost]
public ActionResult StoreItem(FormCollection forms)
{
foreach (string inputTagName in Request.Files)
...
returns null in Request...
Thank you
© Stack Overflow or respective owner