I would like to have different physical upload directories for different users. So, after a user logs in, I store the name of their upload directory into a php $_SESSION['directory'] variable. Fckeditor is embedded into a form on page called contentedit.php. When I check the $_SESSION['directory'] variable at the beginning and end of that page (using echo statements to debug), everything is fine.
When I click the Image icon in Fckeditor and then click the Browse Server button, the browse.php page is correctly invoked, but that page doesn't see any $_SESSION variables at all! (I checked this by putting an echo statement into the browse.php page). I do have a session_start, so I don't understand what happened to the session variables. Any thoughts or suggestions?
--Jeff
When I click the Image icon in Fckeditor and then click the Browse Server button, the browse.php page is correctly invoked, but that page doesn't see any $_SESSION variables at all! (I checked this by putting an echo statement into the browse.php page). I do have a session_start, so I don't understand what happened to the session variables. Any thoughts or suggestions?
--Jeff
RE: Problem setting upload directory dynamica
1. Edit FCKeditor/editor/filemanager/browser/default/browser.html:
After
if ( sServerPath.length > 0 )
oConnector.ConnectorUrl += 'ServerPath=' + escape( sServerPath ) + '&' ;
Add
var sServerAbsolutePath = GetUrlParam( 'ServerAbsolutePath' ) ;
if ( sServerAbsolutePath.length > 0 )
oConnector.ConnectorUrl += 'ServerAbsolutePath=' + escape( sServerAbsolutePath ) + '&' ;
2. In FCKeditor/editor/filemanager/browser/default/connectors/php/config.php, set $Config['Enabled'] = true ;
3. Edit FCKeditor/editor/filemanager/browser/default/connectors/php/connector.php:
After
else
{
// Map the "UserFiles" path to a local directory.
$GLOBALS["UserFilesDirectory"] = GetRootPath() . $GLOBALS["UserFilesPath"] ;
}
Add
if (isset($_GET["ServerAbsolutePath"]))
{
$GLOBALS["UserFilesDirectory"] = $_GET["ServerAbsolutePath"] ;
}
4. In FCKeditor/editor/filemanager/upload/php/config.php, set $Config['Enabled'] = true ;
5. Edit FCKEditor/editor/filemanager/upload/php/upload.php:
After
if ( isset( $Config['UserFilesAbsolutePath'] ) && strlen( $Config['UserFilesAbsolutePath'] ) > 0 )
$sServerDir = $Config['UserFilesAbsolutePath'] ;
else
$sServerDir = GetRootPath() . $Config["UserFilesPath"] ;
Add
if (isset($_GET["ServerAbsolutePath"]))
$sServerDir = $_GET["ServerAbsolutePath"] ;
And After
$sFileUrl = $Config["UserFilesPath"] . $sFileName ;
Add
if (isset($_GET["ServerPath"]))
$sFileUrl = $_GET["ServerPath"].$sFileName;
6. When instantiating the FCKEditor in your application:
include "../FCKeditor/fckeditor.php";
$username = $_SESSION["_username"];
$fckeditor_base_path = "/FCKeditor/";
$fckeditor_upload_virtual_directory = "/app1/uploads/".$username."/";
$fckeditor_upload_physical_directory = "C:\\webapps\\app1\\uploads\\".$username."\\";
$fckeditor = new FCKeditor("content") ;
$fckeditor->BasePath = $fckeditor_base_path;
$fckeditor->Value = "";
$fckeditor->Width = "95%";
$fckeditor->Height = "550";
$fckeditor->Config["LinkBrowserURL"] = ($fckeditor->BasePath)."editor/filemanager/browser/default/browser.html?Connector=connectors/php/connector.php&ServerPath=".$fckeditor_upload_virtual_directory."&ServerAbsolutePath=".$fckeditor_upload_physical_directory;
$fckeditor->Config["ImageBrowserURL"] = ($fckeditor->BasePath)."editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php&ServerPath=".$fckeditor_upload_virtual_directory."&ServerAbsolutePath=".$fckeditor_upload_physical_directory;
$fckeditor->Config["FlashBrowserURL"] = ($fckeditor->BasePath)."editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/php/connector.php&ServerPath=".$fckeditor_upload_virtual_directory."&ServerAbsolutePath=".$fckeditor_upload_physical_directory;
$fckeditor->Config["LinkUploadURL"] = ($fckeditor->BasePath)."editor/filemanager/upload/php/upload.php?ServerPath=".$fckeditor_upload_virtual_directory."&ServerAbsolutePath=".$fckeditor_upload_physical_directory;
$fckeditor->Config["ImageUploadURL"] = ($fckeditor->BasePath)."editor/filemanager/upload/php/upload.php?Type=Image&ServerPath=".$fckeditor_upload_virtual_directory."&ServerAbsolutePath=".$fckeditor_upload_physical_directory;
$fckeditor->Config["FlashUploadURL"] = ($fckeditor->BasePath)."editor/filemanager/upload/php/upload.php?Type=Flash&ServerPath=".$fckeditor_upload_virtual_directory."&ServerAbsolutePath=".$fckeditor_upload_physical_directory;
$fckeditor->Create();
RE: Problem setting upload directory dynamica
FCKEditor/editor/filemanager/upload/php/upload.php:
replace
if ( $Config['UseFileType'] )
$sFileUrl = $Config["UserFilesPath"] . $sType . '/' . $sFileName ;
else
$sFileUrl = $Config["UserFilesPath"] . $sFileName ;
if (isset($_GET["ServerPath"]))
$sFileUrl = $_GET["ServerPath"].$sFileName;
for correct display URL if is set $Config['UseFileType']
if ( $Config['UseFileType'] )
$sFileName = $sType . '/' . $sFileName ;
if (isset($_GET["ServerPath"]))
$sFileUrl = $_GET["ServerPath"] . $sFileName;
else
$sFileUrl = $Config["UserFilesPath"] . $sFileName ;