c# - using plupload jquery in mvc3 HttpPostedFileBase is always null -


overview :

i have use plupload jquery upload multiple files when pressed save button getting null values in httppostedfilebase

code :

   @{     viewbag.title = "imageupload"; } <link href="@url.content("~/scripts/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css")"     rel="stylesheet" type="text/css" /> <link href="@url.content("~/scripts/plupload/js/jquery.ui.plupload/css/jquery.ui.plupload.css")"     rel="stylesheet" type="text/css" /> <script src="@url.content("~/scripts/plupload/js/plupload.full.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/plupload/js/jquery.ui.plupload.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/plupload/js/jquery.plupload.queue/jquery.plupload.queue.js")" type="text/javascript"></script>  <script type="text/javascript">      $(document).ready(function () {          $("#uploader").pluploadqueue({             // general settings             runtimes: 'html5,html4,gears,flash,silverlight',             url: '@url.action("uploadimage")',             max_file_size: '10mb',             chunk_size: '1mb',             unique_names: true,             button_browse_hover: true,             multiple_queues: true,             dragdrop: false,              // resize images on clientside if can             resize: { width: 320, height: 340, quality: 90 },              // specify files browse             filters: [             { title: "image files", extensions: "jpg,gif,png,jpeg,bmp" },             { title: "zip files", extensions: "zip" },             { title: 'pdf files', extensions: 'pdf' },             { title: "excel files", extensions: "xls,xslx,csv" },          ],                // silverlight settings             silverlight_xap_url: '@url.content("~/scripts/plupload/plupload.silverlight.xap")'         });          // client side form validation         $('form').submit(function (e) {              var uploader = $('#uploader').pluploadqueue();             // files in queue upload them first             if (uploader.files.length > 0) {                  if (uploader.files.length < 9) {                     // when files uploaded submit form                     uploader.bind('statechanged', function () {                         if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {                              $('form')[1].submit();                          }                     });                     uploader.start();                 } else {                     alert('number of files more 8.');                 }                 return false;             }             else {                 alert('you must queue @ least 1 file.');             }             return false;         });        });   </script> @using (html.beginform("imageupload", "image", formmethod.post, new { enctype = "multipart/form-data" })) {     <div id="uploader">         <p>             browser doesn't have flash, silverlight, gears, browserplus or html5 support.</p>     </div>     <p>         <input type="submit" value="save" id="uploadfile" name="uploadfile" />     </p>    }    in controller  :          public actionresult imageupload()         {             return view();         } 

i have controller executed on submit of form .

          [httppost]           public string imageupload(httppostedfilebase filedata)           {             filedata = request.files[0];              if (filedata.contentlength > 0)             {                 var filename = path.getfilename(filedata.filename);                 var path = path.combine(server.mappath("~/content"), filename);                 filedata.saveas(path);             }              return "files uploaded successfully!";         } 

replace url: '@url.action("uploadimage")', url: '@url.action("imageupload")',

this works me


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -