0

via http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx

Is there any possibility to dynamicly add <input type="file" name="files" id="file[i]" /> into View (with view model) after clicking button "Add next file", withour reloading page (using jquery)?

Here is main code.

<form action="" method="post" enctype="multipart/form-data">

  <label for="file1">Filename:</label>
  <input type="file" name="files" id="file1" />

  <label for="file2">Filename:</label>
  <input type="file" name="files" id="file2" />

  <input type="submit"  />
</form>

Regards

3
  • why don't you just use multiupload image jquery plugins..instead of creating new file inputs each time ...and letting user upload one file at a time... Commented Jun 19, 2013 at 10:02
  • but what if I don't need to use multiupload jquery plugins? :) I just need to upload 5 or 6 or 7 files, that's all. Commented Jun 19, 2013 at 10:24
  • then its fine... i was just thinking, what if user have to upload 20 files....that is like.. 20 inputs and upload 20 time.. phewww!!!.. :) :) Commented Jun 19, 2013 at 10:29

1 Answer 1

2

You can use the jquery multiple file upload plugin.Take a look here.

Our you can use jquery

$('#Maindiv').append("<label for="file1">Filename:</label><input type="file" name="files" id="file1" />");

set id apt upto your logic.

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

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.