0

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)
  ...

this returns null in Request.

2 Answers 2

2

http://www.plupload.com is awesome

Sign up to request clarification or add additional context in comments.

1 Comment

I was going to post this but I couldn't remember the name. +1
1

You can't POST a file using only javascript.

Look at http://www.uploadify.com/ or something like http://www.swfupload.org/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.