Skip to content

Commit

Permalink
move path resolution to AjaxFileUpload
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailTymchukDX committed Mar 31, 2016
1 parent b06cd9a commit 8d1b6ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion AjaxControlToolkit.Jasmine/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ protected void Application_Start(object sender, EventArgs e) {
RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);

AjaxFileUploadHelper.RootTempFolderPath = HttpContext.Current.Server.MapPath("~/Temp");
AjaxFileUploadHelper.RootTempFolderPath = "~/Temp";
AjaxControlToolkit.ToolkitResourceManager.RegisterControl(typeof(Suites.ToolkitResourceManager.TestExtender));
}

Expand Down
2 changes: 1 addition & 1 deletion AjaxControlToolkit.SampleSite/Global.asax
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));
// In Medium Trust environments, set AjaxFileUploadHelper.RootTempFolderPath to an existing directory located within the web application root.
AjaxFileUploadHelper.RootTempFolderPath = HttpContext.Current.Server.MapPath("~/Temp");
AjaxFileUploadHelper.RootTempFolderPath = "~/Temp";
BundleTable.EnableOptimizations = true;
}
Expand Down
16 changes: 13 additions & 3 deletions AjaxControlToolkit/AjaxFileUpload/AjaxFileUpload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,12 @@ public static string BuildRootTempFolder() {
var userPath = AjaxFileUploadHelper.RootTempFolderPath;

if(userPath != null) {
if(!Directory.Exists(userPath))
throw new IOException(String.Format("Temp directory '{0}' does not exist."));
return userPath;
var physicalPath = GetPhysicalPath(userPath);

if(!Directory.Exists(physicalPath))
throw new IOException(String.Format("Temp directory '{0}' does not exist.", physicalPath));

return physicalPath;
}

var defaultPath = Path.Combine(Path.GetTempPath(), DefaultTempSubDir);
Expand All @@ -405,6 +408,13 @@ public static string BuildRootTempFolder() {
return defaultPath;
}

static string GetPhysicalPath(string path) {
if(path.StartsWith("~"))
return HttpContext.Current.Server.MapPath(path);

return path;
}

internal void CreateChilds() {
Controls.Clear();
CreateChildControls();
Expand Down

0 comments on commit 8d1b6ae

Please sign in to comment.