VS'12 Ineternet Application Template asp.net C# MVC4, EF Code First
Upload Post Method
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);
}
My Questions are
- Why is it not creating my Folders
- When i ( cheat and make them myself ) i have no permissions...
- How can you best upload Dynamically ( I would like to keep uploaded files separately )
- Is there a better way to manage them?
This is for both on the Dev machine though IIS and on my Server-also IIS