is there a good example of how to upload multiple image files in asp.net mvc? I know we can use HttpPostedFileBase to upload one file. Is there a way to upload multiple files by clicking one button?
I used file upload in ajaxtoolbox in webform before and like how it works. Is there a similar way in MVC? or, is there a existing control that can do this well? free control is better, but it is ok even it costs some $.
Thanks
Some of the basic bits required for file uploads
Notice keyword: multiple in input element AND multipart in form element
HTML Side
Controller
Use this jQuery plugin
just include plugin js files, create tag:
(Except IE9 it is not allowing select multiple files in select dialog)
Add some JavaScript:
In controller action just check Request.Files and do whatever you want. Here is a good documentation
You could implement an action with
POST
http verb to that receive a collection ofHttpPostedFileBase
and save all files, for sample:Alternatively, you could read
Request.Files
and do the same job,See Also
I'm using this one. https://www.fyneworks.com/jquery/multiple-file-upload/