1

I have a view within which I have three different text file types/file inputs for example the first input is for .json, the remaining two are similar to .json but different formats which users can upload. Some times for each file type users can have multiple files so currently they zip them up and upload a zip file for a given file type, My code already accomodates zip files.

The request is that users can select multiple files for each file type instead of a zip, for instance if they click browse, they can select two files and so on for each file type. I do realize that asp.net has an upload limit which I can handle.

My question is that the file input type will only allow a user to select single files and not multiple files. Are there any third part utilities that I could use for this multiplescenario? For example there are many internet sites which would allow you to attach multiple files in one browse and click for instance craigs list upload etc.

   <input type="file" name="file" id="file1" style="width: 500px" />

  <input type="file" name="file" id="file2" style="width: 500px" />

  <input type="file" name="file" id="file3" style="width: 500px" />




 [HttpPost]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Create(RunLogEntry runLogEntry, String ServiceRequest,
                                 string submit, string submit1, string submit2, string submit3, IEnumerable<HttpPostedFileBase> file, String AssayPerformanceIssues1, List<string> Replicates)
    {
tereško
  • 58,060
  • 25
  • 98
  • 150
tam tam
  • 1,870
  • 2
  • 21
  • 46
  • Potential duplicate of this question http://stackoverflow.com/questions/1593225/how-to-select-multiple-files-with-input-type-file which has answers you could use to solve the problem – Paul D'Ambra Sep 04 '13 at 18:49

2 Answers2

0

You upload multiple files by modifying the ActionResult method signature:

public ActionResult Index(IEnumerable<HttpPostedFileBase> files) {}

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

Dave Swersky
  • 34,502
  • 9
  • 78
  • 118
  • He already has this if you look at the code he provided. I think what he wants is to allow more file uploads than the 3 he already has - to let the user choose multiple files to upload at once rather than a zip archive. – Erik Noren Sep 03 '13 at 16:48
  • Agree with Erik. I apologize if my problem description was not clear enough. There are many sites out there which allows a user to attach multiple files in one browse and click, for example craigs list etc – tam tam Sep 03 '13 at 17:01
  • Gotcha. Uploadify has a script that can do that. – Dave Swersky Sep 03 '13 at 17:22
0

I unaware of any particular utilities that make this easy. For my purposes, I just create a partial view that has the input for a single file picker. On the main view, I use a helper to render one and use an AJAX action link for the user to click on which will go and get another instance of the partial and add it do the DOM below the first one. In this case the user has to click 'Add New File' and then click again to actually locate the file to upload.

I'm not aware of any method that lets you select multiple files in the file picker dialog without using a plugin.

Erik Noren
  • 4,279
  • 1
  • 23
  • 29