Fix upload bug with files.

This commit is contained in:
Michael 2017-04-05 21:20:12 -04:00
parent a7a111e4ec
commit 78a672ed69

View file

@ -87,7 +87,7 @@ public ActionResult AddRelease(PostDownloadViewModel model)
if (!Directory.Exists(mapped_dir)) if (!Directory.Exists(mapped_dir))
Directory.CreateDirectory(mapped_dir); Directory.CreateDirectory(mapped_dir);
string file_name_d = model.Download.FileName; string file_name_d = model.Download.FileName.ToLower();
foreach(var c in file_name_d.ToCharArray()) foreach(var c in file_name_d.ToCharArray())
{ {
if (!ApprovedIdChars.Contains(c)) if (!ApprovedIdChars.Contains(c))
@ -95,7 +95,7 @@ public ActionResult AddRelease(PostDownloadViewModel model)
} }
download_dir += file_name_d; download_dir += file_name_d;
mapped_dir = Server.MapPath(download_dir); mapped_dir = Server.MapPath(download_dir);
download.DownloadUrl = download_dir; download.DownloadUrl = download_dir.Remove(0, 1);
//Now the download is saved in the DB. Let's get it on the server. //Now the download is saved in the DB. Let's get it on the server.
model.Download.SaveAs(mapped_dir); model.Download.SaveAs(mapped_dir);
@ -104,7 +104,7 @@ public ActionResult AddRelease(PostDownloadViewModel model)
if (!Directory.Exists(mapped_dir)) if (!Directory.Exists(mapped_dir))
Directory.CreateDirectory(mapped_dir); Directory.CreateDirectory(mapped_dir);
file_name_d = model.Screenshot.FileName; file_name_d = model.Screenshot.FileName.ToLower(); ;
foreach (var c in file_name_d.ToCharArray()) foreach (var c in file_name_d.ToCharArray())
{ {
if (!ApprovedIdChars.Contains(c)) if (!ApprovedIdChars.Contains(c))
@ -112,7 +112,7 @@ public ActionResult AddRelease(PostDownloadViewModel model)
} }
download_dir += file_name_d; download_dir += file_name_d;
mapped_dir = Server.MapPath(download_dir); mapped_dir = Server.MapPath(download_dir);
download.ScreenshotUrl = download_dir; download.ScreenshotUrl = download_dir.Remove(0,1);
model.Screenshot.SaveAs(mapped_dir); model.Screenshot.SaveAs(mapped_dir);
//Now we just save to the database... //Now we just save to the database...