Menu

#154 [filemanager] Set a specific directory for each file type

Version 2.x
closed
Editor (144)
5
2014-08-23
2005-10-04
No

Hi,
if you add the fckeditor to an existing webiste,
there's chance that file, flash, image and media
folders already exist, with names that doesn't match
the fckeditor ones and not placed under the same directory.

So I add a way to specified a directory for each file
type for php and asp filemanager :
in the <fckeditor
dir>/editor/filemanager/browser/default/connectors

====PHP====

*edit php/config.php as follow :

add the follwing lines after each
"$Config['DeniedExtensions']" setting:

$Config['ConfigDirectories']['File'] = "your files dir";
$Config['ConfigDirectories']['Image'] = "your images
dir";
$Config['ConfigDirectories']['Flash'] = "your flash
dir";
$Config['ConfigDirectories']['Media'] = "your media
dir ";

*edit php/io.php as follow :

at the start of GetUrlFromPath and ServerMapFolder
functions add :
global $Config ;

then replace each use of :
$resourceType
by
$Config['ConfigDirectories'][$resourceType]

====ASP====

*edit asp/config.asp as follow :

at the end of the dictionnary definition add :
Set ConfigDirectories = CreateObject(
"Scripting.Dictionary" )

after each "ConfigDeniedExtensions.Add " setting add :
ConfigDirectories.Add "File", "your files dir"
ConfigDirectories.Add "Image", "your images dir"
ConfigDirectories.Add "Flash", "your flash dir"
ConfigDirectories.Add "Media", "your media dir"

*edit asp/io.asp as follow :

in the GetUrlFromPath and ServerMapFolder functions
replace each use of :
resourceType
by
ConfigDirectories.Item( resourceType)

Discussion

1 2 > >> (Page 1 of 2)
  • Nobody/Anonymous

    Logged In: NO

    do you have an example? I get xml internal server error

     
  • arathael

    arathael - 2006-06-09

    Logged In: YES
    user_id=1406780

    Really thanks, i had this fu**ing issue on my free host and
    i didnt know how to fix it without hacking the config
    variables...

    So, i used your method to make a good hack out of it!!

    Thanks again

     
  • Nobody/Anonymous

    Logged In: NO

    asdfasdfsa

     
  • Nobody/Anonymous

    Logged In: NO

    This simply doesn't work.

    Still no other recoursetype than Image to select, no upload
    ever works and no idea where the files should be placed.

    I debug this on a windoze local machine, so rights are not
    the issue.

     
  • Nobody/Anonymous

    Logged In: NO

    Just thought i'd let people know - This does work dispite
    the previous comment.

    It's important to get the

    $Config['UserFilesPath']
    $Config['UserFilesAbsolutePath']

    Variables (in
    editor/filemanager/browser/default/connectors/php/config.php)
    correct as well.

    UserFilesPath controls the prefix prefixed to the
    folder/file_name.xxx when insterted into the webpage (think
    http://mysite.com/ as a value)

    UserFilesAbsolutePath controls the starting point for all
    media types. I had all my media files in "images" so i used
    something similar to "/root/mysite/images" as a value.

    I also changed 1 thing in io.php that isnt listed here...

    Changed "if ( $resourceType == '' )" to "if ( $resourceType
    == '' || $Config['ConfigDirectories'][$resourceType] == '')"
    in function getUrlFromPath() as i set my media specific
    paths to "" because i want 'em all in the images/ directory.

    Anyway, coulda found this on my own, but nice to not have to
    go searching through files w/o a starting point (osCommerce
    anyone?)

    Pay me to hack it for you? sean at syosis dot com

     
  • aktizol

    aktizol - 2006-06-29

    Logged In: YES
    user_id=1118007

    Is there any solution/example for COLDFUSION applications?

    Thank you.

     
  • Nobody/Anonymous

    Logged In: NO

    For cold fusion, I guest the folowing modification should do
    the job :

    *edit cfm/config.cfm as follow :

    * add the following lines after
    config.deniedExtensions["Media"] = ""; :

    config.configDirectories["File"] = "your files dir";
    config.configDirectories["Image"] = "your images dir";
    config.configDirectories["Flash"] = "your flash dir";
    config.configDirectories["Media"] = "your media dir ";

    * then edit cfm/connector.cfm as follow :
    replace each "& url.type"
    by
    "& config.configDirectories[url.type]"
    (ignore the quotes)

     
  • aktizol

    aktizol - 2006-06-30

    Logged In: YES
    user_id=1118007

    ok, i just did it!
    but it doesn't work ;-(

    it is still creating this "Image" folder ....

     
  • aktizol

    aktizol - 2006-07-01

    Logged In: YES
    user_id=1118007

    any ideas as for the COLDFUSION to work?

    thank you.

     
  • irashkin

    irashkin - 2006-07-12

    Logged In: YES
    user_id=1052118

    Two addendums to the coldfusion implementation (I struggled
    a long time with this because of not actually looking at
    what I was doing, just copying code...).

    Below "config.deniedExtensions = structNew();",
    add "config.ConfigDirectories = structNew();"
    (without the quotes of course)!

    Also, change line "<cfdirectory action="create"
    directory="#userFilesServerPath##url.type#" mode="755">"
    to "<cfdirectory action="create"
    directory="#userFilesServerPath##config.ConfigDirectories[url.type]#"
    mode="755">".

    Further watch out for the following - I kept getting an
    error in the xml and couldn't figure out why. At last I
    realized that some of the filenames had illegal (for xml)
    chars in them (not my doing!). So I changed the following in
    connector.cfm:

    "files = files & '<File name="#qDir.name[i]#" size="#IIf(
    fileSizeKB GT 0, DE( fileSizeKB ), 1)#" />';""
    to
    "filename = qDir.name[i];
    filename = replace(filename, "&", "&amp;", "ALL");
    filename = replace(filename, "'", "&apos;", "ALL");
    filename = replace(filename, """", "&aquot;", "ALL");
    filename = replace(filename, "<", "&gt;", "ALL");
    filename = replace(filename, "<", "&lt;", "ALL");
    files = files & '<File name="#filename#" size="#IIf(
    fileSizeKB GT 0, DE( fileSizeKB ), 1)#" />';"'

    I still get a javascript error in IE when viewing a dir, but
    I can't find the error, and it doesn't impede functionality,
    so I'm happy.

     
  • Nobody/Anonymous

    Logged In: NO

    I doesn't work, have i done something wrong?

    In config.php I changed:
    $Config['AllowedExtensions']['File'] = array() ;
    $Config['DeniedExtensions']['File'] = array
    ('php','php2','php3','php4','php5','phtml','pwml','inc','as
    p','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','com','
    dll','vbs','js','reg','cgi') ;
    $Config['ConfigDirectories']['File'] = "/files/";

    And in io.php I changed every $resourceType and put global
    $Config in it:

    function GetUrlFromPath( $Config['ConfigDirectories']
    [$resourceType], $folderPath )
    {
    global $Config ;

    if ( $Config['ConfigDirectories'][$resourceType]
    == '' )
    return RemoveFromEnd( $GLOBALS
    ["UserFilesPath"], '/' ) . $folderPath ;
    else
    return $GLOBALS["UserFilesPath"] . $Config
    ['ConfigDirectories'][$resourceType] . $folderPath ;
    }

    function RemoveExtension( $fileName )
    {
    return substr( $fileName, 0, strrpos(
    $fileName, '.' ) ) ;
    }

    function ServerMapFolder( $Config['ConfigDirectories']
    [$resourceType], $folderPath )
    {

    global $Config ;

    // Get the resource type directory.
    $sResourceTypePath = $GLOBALS
    ["UserFilesDirectory"] . $Config['ConfigDirectories']
    [$resourceType] . '/' ;

    // Ensure that the directory exists.
    CreateServerFolder( $sResourceTypePath ) ;

    // Return the resource type directory combined
    with the required path.
    return $sResourceTypePath . RemoveFromStart(
    $folderPath, '/' ) ;
    }

     
  • Nobody/Anonymous

    Logged In: NO

    I doesn't work, have i done something wrong?

    In config.php I changed:
    $Config['AllowedExtensions']['File'] = array() ;
    $Config['DeniedExtensions']['File'] = array
    ('php','php2','php3','php4','php5','phtml','pwml','inc','as
    p','aspx','ascx','jsp','cfm','cfc','pl','bat','exe','com','
    dll','vbs','js','reg','cgi') ;
    $Config['ConfigDirectories']['File'] = "/files/";

    And in io.php I changed every $resourceType and put global
    $Config in it:

    function GetUrlFromPath( $Config['ConfigDirectories']
    [$resourceType], $folderPath )
    {
    global $Config ;

    if ( $Config['ConfigDirectories'][$resourceType]
    == '' )
    return RemoveFromEnd( $GLOBALS
    ["UserFilesPath"], '/' ) . $folderPath ;
    else
    return $GLOBALS["UserFilesPath"] . $Config
    ['ConfigDirectories'][$resourceType] . $folderPath ;
    }

    function RemoveExtension( $fileName )
    {
    return substr( $fileName, 0, strrpos(
    $fileName, '.' ) ) ;
    }

    function ServerMapFolder( $Config['ConfigDirectories']
    [$resourceType], $folderPath )
    {

    global $Config ;

    // Get the resource type directory.
    $sResourceTypePath = $GLOBALS
    ["UserFilesDirectory"] . $Config['ConfigDirectories']
    [$resourceType] . '/' ;

    // Ensure that the directory exists.
    CreateServerFolder( $sResourceTypePath ) ;

    // Return the resource type directory combined
    with the required path.
    return $sResourceTypePath . RemoveFromStart(
    $folderPath, '/' ) ;
    }

     
  • aktizol

    aktizol - 2006-07-19

    Logged In: YES
    user_id=1118007

    irashkin's implementation for coldfusion works just fine!
    thanks again.

     
  • Scott M Johnson

    Scott M Johnson - 2006-07-26

    Logged In: YES
    user_id=741769

    This for PHP users, maybe even ASP users:

    When Oliver said:
    "then replace each use of :
    $resourceType
    by
    $Config['ConfigDirectories'][$resourceType]"

    He didn't actually mean every single use of '$resourceType'.
    The only instances you DO NOT change is:

    function GetUrlFromPath( $resourceType, $folderPath ) {
    ...
    }

    AND

    function ServerMapFolder( $resourceType, $folderPath ) {
    ...
    }

    You only change '$resourceType' inside the function, and not
    in the function arguments.

     
  • rem1th0mas

    rem1th0mas - 2006-07-31

    Logged In: YES
    user_id=1565265

    - asp users -
    Got a lot of troubles with the hack but I did manage at the
    end:

    Note that it wouldn't be possible to debug without this
    file installed:
    /fckeditor/editor/filemanager/browser/default/connectors/tes
    t.html

    - in config.asp, don't forget to DIM the var
    ConfigDirectories (line 29)

    I suggest that you set up ConfigUserFilesPath = "/" (eg
    start from the root)

    then if your images are located at
    /a_directory/another_sub_directory

    ConfigDirectories.Add "Image", "a_directory/another_sub_dire
    ctory"

    and if your files are located at
    /another_directory/a_sub_directory

    ConfigDirectories.Add "File", "another_directory/a_sub_direc
    tory"

    - in IO.asp
    change line 24 as per Olivier first message:
    GetUrlFromPath = sUserFilesPath & ConfigDirectories.Item
    (resourceType) & folderPath

    and also line 35 as per Olivier first message:
    sResourceTypePath = sUserFilesDirectory &
    ConfigDirectories.Item(resourceType) & "\"

    - connector.asp - no change.

    Make sure you set up your permission right in IIS.

    As soon as you can list folders and files in test.html then
    you're sorted.
    Good luck!

     
  • rem1th0mas

    rem1th0mas - 2006-07-31

    Logged In: YES
    user_id=1565265

    - asp users -
    Got a lot of troubles with the hack but I did manage at the
    end:

    Note that it wouldn't be possible to debug without this
    file installed:
    /fckeditor/editor/filemanager/browser/default/connectors/tes
    t.html

    - in config.asp, don't forget to DIM the var
    ConfigDirectories (line 29)

    I suggest that you set up ConfigUserFilesPath = "/" (eg
    start from the root)

    then if your images are located at
    /a_directory/another_sub_directory

    ConfigDirectories.Add "Image", "a_directory/another_sub_dire
    ctory"

    and if your files are located at
    /another_directory/a_sub_directory

    ConfigDirectories.Add "File", "another_directory/a_sub_direc
    tory"

    - in IO.asp
    change line 24 as per Olivier first message:
    GetUrlFromPath = sUserFilesPath & ConfigDirectories.Item
    (resourceType) & folderPath

    and also line 35 as per Olivier first message:
    sResourceTypePath = sUserFilesDirectory &
    ConfigDirectories.Item(resourceType) & "\"

    - connector.asp - no change.

    Make sure you set up your permission right in IIS.

    As soon as you can list folders and files in test.html then
    you're sorted.
    Good luck!

     
  • rem1th0mas

    rem1th0mas - 2006-07-31

    Logged In: YES
    user_id=1565265

    - asp users -
    Got a lot of troubles with the hack but I did manage at the
    end:

    Note that it wouldn't be possible to debug without this
    file installed:
    /fckeditor/editor/filemanager/browser/default/connectors/tes
    t.html

    - in config.asp, don't forget to DIM the var
    ConfigDirectories (line 29)

    I suggest that you set up ConfigUserFilesPath = "/" (eg
    start from the root)

    then if your images are located at
    /a_directory/another_sub_directory

    ConfigDirectories.Add "Image", "a_directory/another_sub_dire
    ctory"

    and if your files are located at
    /another_directory/a_sub_directory

    ConfigDirectories.Add "File", "another_directory/a_sub_direc
    tory"

    - in IO.asp
    change line 24 as per Olivier first message:
    GetUrlFromPath = sUserFilesPath & ConfigDirectories.Item
    (resourceType) & folderPath

    and also line 35 as per Olivier first message:
    sResourceTypePath = sUserFilesDirectory &
    ConfigDirectories.Item(resourceType) & "\"

    - connector.asp - no change.

    Make sure you set up your permission right in IIS.

    As soon as you can list folders and files in test.html then
    you're sorted.
    Good luck!

     
  • rem1th0mas

    rem1th0mas - 2006-07-31

    Logged In: YES
    user_id=1565265

    - asp users -
    Got a lot of troubles with the hack but I did manage at the
    end:

    Note that it wouldn't be possible to debug without this
    file installed:
    /fckeditor/editor/filemanager/browser/default/connectors/tes
    t.html

    - in config.asp, don't forget to DIM the var
    ConfigDirectories (line 29)

    I suggest that you set up ConfigUserFilesPath = "/" (eg
    start from the root)

    then if your images are located at
    /a_directory/another_sub_directory

    ConfigDirectories.Add "Image", "a_directory/another_sub_dire
    ctory"

    and if your files are located at
    /another_directory/a_sub_directory

    ConfigDirectories.Add "File", "another_directory/a_sub_direc
    tory"

    - in IO.asp
    change line 24 as per Olivier first message:
    GetUrlFromPath = sUserFilesPath & ConfigDirectories.Item
    (resourceType) & folderPath

    and also line 35 as per Olivier first message:
    sResourceTypePath = sUserFilesDirectory &
    ConfigDirectories.Item(resourceType) & "\"

    - connector.asp - no change.

    Make sure you set up your permission right in IIS.

    As soon as you can list folders and files in test.html then
    you're sorted.
    Good luck!

     
  • rem1th0mas

    rem1th0mas - 2006-07-31

    Logged In: YES
    user_id=1565265

    ooppps sorry for multi posting, got error 500 everytime i
    pressed the submit button.

     
  • Nobody/Anonymous

    Logged In: NO

    sasa

     
  • Nobody/Anonymous

    Logged In: NO

    for asp code u must declare ConfigDirectories as
    Dim ConfigDirectories

     
  • Manish Hatwalne

    Manish Hatwalne - 2006-08-30

    Logged In: YES
    user_id=764730

    How do I set my own directory for "File" type resource in Java??

     
  • Manish Hatwalne

    Manish Hatwalne - 2006-08-30

    Logged In: YES
    user_id=764730

    How do I set my own directory for "File" type resource in Java??

     
  • Manish Hatwalne

    Manish Hatwalne - 2006-08-30

    Logged In: YES
    user_id=764730

    I had a look at "ConnectorServlet" as well as
    "SimpleUploaderServlet" and looks like it is not possible as
    of now to do this using Java. Maybe I can offer a patch to
    do this in Java -- may I?

    rgds,
    - Manish

     
  • Nobody/Anonymous

    Logged In: NO

    dfdfdf

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

MongoDB Logo MongoDB