Hi.
After browsing some posts I realized that this is a common issue:
Behavior:
If you set the UserFilesPath with a "~" ("~/MiFolder/") like URL you don't see the image in the preview area nor in the editor once you select it (althounght the file browser and uploads work ok)
None of the other alternatives works at all ("/MiFolder/" ; ''./MiFolder/" ; ".././MiFolder" ...)
Forum commonly offered solution involves hardcoding the URL:
StrHTML = Replace(StrHTML,"src=""/userfiles/images/","src=""http://www.somesite.com/userfiles/images/")
Others some JavaScript url detecting (post: http://sourceforge.net/forum/forum.php? ... _id=257180)
If you want to have it solved from .NET code, here is an alternative:
1) If web.config add a line to choose the editor to autocompleteURLs. Something like:
<appSettings>
<add key="FCKeditor:BasePath" value="~/FCKeditor/" />
<add key="FCKeditor:UserFilesPath" value="/MiFolder/UploadedFiles/" />
<add key="FCKeditor:AutoCompleteAlsoluteURL" value="1" />
</appSettings>
2) Then open FileWorkerBase.cs file and add some lines where it retrieves the path from Web.config, about line 45 (I am assuming you are setting this there, otherwise, place this lines where you set the UserFilesPath, IE: Session)
sUserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"] ;
//NEW LINES
if (sUserFilesPath != null && sUserFilesPath.Length != 0)
{
string sComplete; //Retrieve the optional URLAutocomplete option
sComplete = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:AutoCompleteAlsoluteURL"];
if (sComplete == "1") //If it is set to 1 then detect and Autocomplete the full url path
{
sUserFilesPath = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + System.Web.HttpContext.Current.Request.ApplicationPath + sUserFilesPath;
}
}
//END NEW LINES
3) Then in the block where this code file gets the local (server) directory path translation, replace the line (about 90) with:
sUserFilesDirectory = Server.MapPath(this.UserFilesPath.Substring(this.UserFilesPath.IndexOf(System.Web.HttpContext.Current.Request.ApplicationPath))); //This is made to let the MapPath function to solve a valid relative path, otherwise an exception will occur.
4) Recompile the dll and replace it in the bin directory of your web application (unless you are using FCK.NET as a project in your solution. In that case, ignore this step)
Thats all. Now your image browser / uploader will detect and use full url automatically no matters the server you publish the Web apllication or the directory you choose to upload files.
Also, you will now see images on preview panel and editor's area (cause FCK will be using full URL)
Hope this helps.
Leonardo
Fri, 09/14/2007 - 20:01
#1