Setting up the Document Path

Rich Text Editor for PHP

To enable the document management function of the RichTextEditor control, you must set up a managed document folder.

This is simply a folder in which you will be placing document for your users to use in their content. Create a folder in your application's root folder. The folder can be named something like "/uploads/", "/documents" or "/UserDocument".

Make sure that the Internet Guest Account has Read+Write permissions on this folder and its contents.

How to specify the document path?

You can easily specify the document path using the following methods:

Edit security policy file

The security policy file (default.config, admin.config and guest.config) can be found in the richtexteditor/config folder. In security policy file you can find the following code which defines the document path information within RichTextEditor. By default, insert document dialog has the following settings:

<category for="Document"><!-- Insert Document Dialog -->  
       <security name="Extensions">*.txt,*.doc,*.pdf,*.zip,*.rar,*.htm,*.xls,*.html,*.rtf</security>
       <storage id="default>
              <security name="StoragePath">~/uploads</security>
              <security name="StorageName">Document Files</security><!-- storage display name -->
       </storage>
</category>

If you want to add new folders as document path, you need to create new storages and specify the storgae ID, name, path.

<category for="Document">
       <storage id="newdocumentpath>
              <security name="StorageName">New Document</security><!-- storage display name -->
              <security name="StoragePath">~/newdocumentpath</security>
       </storage>
       <storage id="newdocumentpath2>
              <security name="StorageName">New Document2</security><!-- storage display name -->
              <security name="StoragePath">~/newdocumentpath2</security>
       </storage>
</category>

Programmatically specify the document path

RichTextEditor provides a powerful method named Editor.SetSecurity that allows you programmatically manage the security settings.

1. Set document path using the default storage

$rte->SetSecurity("Document", "default", "StoragePath", "~/uploads"); 
$rte->SetSecurity("Document", "default", "StorageName", "Uploads");

This is equivalent to the following code:

<category for="Document"><!-- Document Dialog -->  
       <storage id="default>
              <security name="StoragePath">~/uploads</security>
              <security name="StorageName">Document Files</security><!-- storage display name -->
       </storage>
</category>

2. Create a new storage for insert document dialog and specify the ID, name and path

$rte->SetSecurity("Document", "newdocumentpath", "StoragePath", "~/newdocumentpath"); 
$rte->SetSecurity("Document", "newdocumentpath ", "StorageName", "New Document");

This is equivalent to the following code:

<category for="Document">
       <storage id="newdocumentpath>
              <security name="StorageName">New Document</security>
              <security name="StoragePath">~/newdocumentpath</security>
       </storage>
</category>

3. To programmatically disable a storage access, you can use the following method:

$rte->SetSecurity("Document", "newdocumentpath", "AllowAccess", "false"); 

In the above code, insert document dialog access to a storage is disabled. The storage ID in the above code is "newdocumentpath".


Send feedback about this topic to CuteSoft. © 2003 - 2012 CuteSoft Components Inc. All rights reserved.