title: Large file upload and download ASP .NET MVC4
body: <p>Can anybody give me example of code for uploading and downloading different type of files by Using <code>Custom Control</code> in <code>ASP</code> <code>.NET</code> <code>MVC4</code> by using <code>PlUpload</code> Plugin.  I want to save files for my task, message with unique Ids in database and want to retrieve them too.  Here is my code that I tried for uploading</p>
  
  <p>server side</p>
  
  <pre><code>public ActionResult UploadFiles(string id)
  {
  for (int i = 0; i &lt; Request.Files.Count; i++)
  {
      var file = Request.Files[i];
  
  
  
      file.SaveAs(AppDomain.CurrentDomain.BaseDirectory + "Uploads/" + file.FileName);
  }
  return Json(new { success = true }, JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>and for plupload plugin code for client side for uploading file is</p>
  
  <pre><code>$("#file_attachments").pluploadQueue(
  {
      // General settings
      runtimes: 'html5,flash,silverlight',
      url: '/SideMenuBar/UploadFiles',
      max_file_size: '100mb',
      chunk_size: '1mb',
      unique_names: true,
  
      multipart: true,
      // Specify what files to browse for
      filters: [
          { title: "Image files", extensions: "jpg,gif,png" },
          { title: "Zip files", extensions: "zip" },
          { title: "Rar files", extensions: "rar" },
          { title: "Document files", extensions: "docx,doc,xlx,xlxs,ppt" },
  
      ],
      // Flash settings
      flash_swf_url: 'Script/lib/plupload/js/plupload.flash.swf',
      // Silverlight settings
      silverlight_xap_url: 'Script/lib/plupload/js/plupload.silverlight.xap',
      // PreInit events, bound before any internal events
      preinit: {
          Init: function (up, info) {
                  //alert('[Init]'+ info+ 'Features:'+ up.features);
          },
  
          UploadFile: function (up, file) {
              //  alert('[UploadFile]', file);
              // You can override settings before the file is uploaded
              up.settings.url = '/SideMenuBar/UploadFiles?id=' + file.id;
              //up.settings.multipart_params = {param1: 'value1', param2: 'value2'};
          }
      },
  
      // Post init events, bound after the internal events
      init: 
          UploadComplete: function (up, files) {
              // destroy the uploader and init a new one
              up.destroy();
          }
      }
      });
  
     var uploader = $('#file_attachments').pluploadQueue();
     uploader.bind('FileUploaded', function (upldr, file, object) {
  
         if (uploader.files.length == (uploader.total.uploaded + uploader.total.failed)) {
             $(".file_upload_cancel").hide();
              $(".file_upload_done").show();
          }
     });
     uploader.bind("FilesAdded", function (up, filesToBeAdded) {
         if (up.files.length &gt; 5) {
             up.files.splice(4, up.files.length - 5);
             showStatus("Only 5 files max are allowed per upload. Extra files removed.", 3000, true);
             return false;
         }
         return true;
     });
      $('.upload_files').click(function (e) {
          e.preventDefault();
          $(".file_up").show();
      });
      $('#new_message_form').submit(function (e) {
          var uploader = $('#file_attachments').pluploadQueue();
          // Files in queue upload them first
          if (uploader.files.length &gt; 0) {
              // When all files are uploaded submit form
              uploader.bind('StateChanged', function () {
                  if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed))              {
                      //uncoment next line to submit form after all files are uploaded
                      //$('#new_message_form')[0].submit();
                  }
              });
              uploader.start();
          }
          return false;
      });
  </code></pre>
  
  <p>}</p>
  
  <p>How can I resolve problem</p>