title: MVC : Upload List of files and save in Folder(name-GUID) for individual
body: <p>I want to upload multiple files from the various user and saves them all at server with individual folder for each user,which contains list of uploaded files by him.</p>
  
  <p>Requirement:If user uploads 5 files,all five files will be stored within a single folder with GUID FolderName.</p>
  
  <p>My below code creates a new folder for each files upload by a user.
  Ex:If user uploads 5 files,all five files will be stored within five different folder with GUID FolderName.</p>
  
  <p>My Controller Upload method is as shown below:</p>
  
  <pre><code> ##Controller Code##
  
      public string Upload(HttpPostedFileBase fileData)
      {            var testfolder = this.Server.MapPath("~/uploads/");
               string newGuid = Guid.NewGuid().ToString();
               string pathToCreate = Path.Combine(testfolder, newGuid);
               if (!System.IO.Directory.Exists(pathToCreate))
               {
                   System.IO.Directory.CreateDirectory(System.IO.Path.Combine(testfolder, newGuid));
               }
               var fileName = pathToCreate + "//" + System.IO.Path.GetFileName(file.FileName);
               file.SaveAs(fileName);                              
               return "OK"; 
       }
  </code></pre>
  
  <p>##View Code##</p>
  
  <pre><code>  @{
    Layout = "~/Views/Shared/_Layout.cshtml";
    }
     &lt;link href="@Href("~/Content/uploadify.css")" rel="stylesheet" /&gt;
   &lt;link href="@Href("~/Content/bootstrap.css")" rel="stylesheet" type="text/css" /&gt;
   &lt;div class="row"&gt;
   &lt;div style="width: 50%;"&gt;
  
          &lt;input type="file" id="multipleFiles" style="width: 50%;" /&gt;&lt;div style="width:     77%;
              float: right" id="progressbar"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="fileQueue"&gt;&lt;/div&gt;
     &lt;/div&gt;
          &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"                          type="text/javascript"&gt;&lt;/script&gt;
       &lt;script src="@Href("~/Scripts/jquery-1.9.1.js")" type="text/javascript"&gt;&lt;/script&gt;
        &lt;script src="@Href("~/Scripts/bootstrap.js")" type="text/javascript"&gt;&lt;/script&gt;
  
          &lt;script src="@Href("~/Scripts/jquery.uploadify.js")" type="text/javascript"&gt;   &lt;/script&gt;
          &lt;script type="text/javascript"&gt;
  
           $(function () {
       $("#multipleFiles").uploadify({
          'swf': 'Scripts/uploadify.swf',
          'cancelImg': '/Images/trash.jpg',
          'buttonText': 'Add Documents',
          'uploader': 'Upload/Upload',
          'folder': '/uploads',
          'dataType': 'json',
          'fileDesc': 'Image Files',
          'fileExt': '', //'*.jpg;*.jpeg;*.gif;*.png',
          'multi': true,
          'removeCompleted': false,
          'auto': false,
          'height': '30px',
          'queueID': 'fileQueue'
             });
     });
  &lt;/script&gt;
  </code></pre>