title: Uploading in MVC Dynamically creating folder with persmissions
body: <p><em>VS'12 Ineternet Application Template asp.net C# MVC4, EF Code First</em></p>
  
  <blockquote>
    <p><strong>Upload Post Method</strong></p>
  </blockquote>
  
  <pre><code>if (ModelState.IsValid)
          {        
                  foreach (var file in attachments)
                  {
                      string strMappath = "~/UploadedImages/" +var1+ "/" + var2+ "/" + var3+ "/" + var4+ "/" + var5 + "/";
  
                      if (!Directory.Exists(strMappath))
                      {
                          DirectoryInfo di = Directory.CreateDirectory(strMappath);
                      }
  
                      // Some browsers send file names with full path. We only care about the file name.
                      //var fileName = Path.GetFileName(file.FileName);
                      var fileName = Path.GetFileNameWithoutExtension(file.FileName) + Path.GetExtension(file.FileName);
  
                      var destinationPath = Path.Combine(
                          Server.MapPath(strMappath), fileName);
                      file.SaveAs(destinationPath);
                  }
  </code></pre>
  
  <p><strong>My Questions are</strong> </p>
  
  <ol>
  <li>Why is it not creating my Folders</li>
  <li>When i ( cheat and make them myself ) i have no permissions...</li>
  <li>How can you best upload Dynamically ( I would like to keep uploaded files separately ) </li>
  <li>Is there a better way to manage them?</li>
  </ol>
  
  <p><em>This is for both on the Dev machine though IIS and on my Server-also IIS</em></p>