Skip to main content
PHP HTML Editor

Deployment guide

Five steps from the download to a working editor with uploads on your server.

1. Copy the folder

Copy the richtexteditor folder from the download to your web root, so its scripts are served from /richtexteditor/. In a sub folder, set $editor->runtimeUrl to its URL.

2. Add the editor to a page

<?php
require_once 'richtexteditor/include_rte.php';
$rte = new RichTextEditor();
$rte->Name = 'Body';
$rte->MvcInit();          // before any output
?>
<form method="post"><?php echo $rte->GetString(); ?><button>Save</button></form>

Read the result with RichTextEditor::GetPostedHtml('Body'). Call MvcInit() (or handleRequest() in the modern API) before the page writes anything: it answers the editor's uploads and starts the session that protects them.

3. Choose the policy per user

Set SecurityPolicyFile from your login system: guest.config (browse only), default.config (upload and create folders) or admin.config (everything). Edit the files in richtexteditor/config to change folders, types and limits; the policy reference lists every setting.

4. Let the web server write the upload folders

  • IIS: give the application pool identity (or IIS_IUSRS) Modify permission on uploads. In IIS Manager, check Request Filtering > Edit Feature Settings > Maximum allowed content length (30 MB by default).
  • Apache / nginx: make uploads writable by the PHP user, for example chown -R www-data uploads.
  • php.ini: upload_max_filesize and post_max_size must be at least your policy's MaxFileSize; PHP's default is 2 MB.

5. Stop scripts from running in the upload folders

PHP HTML Editor never stores PHP, ASP, HTML or SVG files. As a second line of defence, tell the web server never to run code from uploads:

IIS: uploads/web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
        <fileExtensions allowUnlisted="true">
          <add fileExtension=".php" allowed="false" />
          <add fileExtension=".phtml" allowed="false" />
          <add fileExtension=".asp" allowed="false" />
          <add fileExtension=".aspx" allowed="false" />
          <add fileExtension=".config" allowed="false" />
        </fileExtensions>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

Apache: uploads/.htaccess

<FilesMatch "\.(php[0-9]?|phtml|phar)$">
    Require all denied
</FilesMatch>
php_flag engine off

(php_flag works with mod_php only; remove the line under PHP-FPM.)

nginx

location ^~ /uploads/ {
    location ~ \.php$ { deny all; }
}
# policy files are read by PHP, never by visitors (IIS and the included .htaccess already block them)
location ^~ /richtexteditor/config/ { deny all; }

Check it works

Open the page, use Insert Gallery and upload an image. If the upload fails, the message names the cause (permissions, file type, size); the server's PHP error log has the details of anything else.