Asp.net MVC: upload multiple image files? -


is there example of how upload multiple image files in asp.net mvc? know can use httppostedfilebase upload 1 file. there way upload multiple files clicking 1 button?

i used file upload in ajaxtoolbox in webform before , how works. there similar way in mvc? or, there existing control can well? free control better, ok costs $.

thanks

use jquery plugin

just include plugin js files, create tag:

<input type='file' multiple id='fileupload' name="files[]" data-url="@url.action("upload","home")" /> 

(except ie9 not allowing select multiple files in select dialog)

add javascript:

$(function () {     $('#fileupload').fileupload({         datatype: 'json',         done: function (e, data) {             $.each(data.result.files, function (index, file) {                 $('<p/>').text(file.name).appendto(document.body);             });         }     }); }); 

in controller action check request.files , whatever want. here documentation

[httppost] public jsonresult upload()  {     foreach (var file in request.files)     {         if(file.contentlength > 0)         {             file.saveas(server.mappath("~/upload/" + file.filename));         }     }      return json(new { result = true }); } 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -