How can I insert images into a Redactor rich text field in a front-end form? I want to allow registered users to insert (i.e. upload) images into a Redactor rich text field in a front-end form.

I dowloaded the Image Manager plugin from Imperavi (https://imperavi.com/redactor/plugins/imagemanager/) and set up my Redactor config as follows:

{% includeJsResource "lib/redactor/redactor.js" %}
{% includeJsResource "lib/redactor/plugins/source.js" %}
{% includeJsResource "lib/redactor/plugins/fullscreen.js" %}
{% includeJsResource "lib/redactor/plugins/imagemanager.js" %}
{% includeCssResource "lib/redactor/redactor.css" %}

{% set redactorJS %}
    $('#{{ elId }}').redactor({
        buttons: ['format', 'bold', 'italic', 'deleted', 'lists', 'link', 'html', 'image'],
        formatting: ['p', 'blockquote', 'h2', 'h3'],
        plugins: ['source','fullscreen', 'imagemanager'],
        minHeight: 300,
        imageUpload: '/upload.php',
    });
{% endset %}
{% includeJs redactorJS %}


I can see the image button in the toolbar and the browse files modal when I click the image button. However, it doesn’t upload anything because imageUpload: '/upload.php', is obviously incorrect. What, if anything, can I replace upload.php with? If this isn’t possible, what else could I do to achieve this functionality? Thanks!

UPDATE:

I have the following code in craft/plugins/imagesuploaderscript/controllers/ImagesUploaderScriptController.php from CloudApp share link in comment below:

namespace Craft;


class ImagesUploaderScriptController extends BaseController
{

protected $valid_extensions = array('jpg', 'jpeg', 'png');
protected $assetSourceId = 1;
protected $assetFolderId = 1;

public function actionUpload()
{
    $this-&gt;requireAjaxRequest();

    $errors = array();
    $success = array();

    if (!$_FILES['file']['error'])
    {
        $filename = $_FILES['file']['name'];
        $file = $_FILES['file']['tmp_name'];
        $extension = pathinfo($filename, PATHINFO_EXTENSION);

        if (!in_array($extension, $this-&gt;valid_extensions))
        {
            $errors[] = "$filename has an invalid extension.";
        } else {
            $uploadDir = craft()-&gt;assetSources-&gt;getSourceById($this-&gt;assetSourceId)-&gt;settings['path'];

            if (move_uploaded_file($file, $uploadDir . $filename))
            {
                IOHelper::deleteFile($file);

                $file = $uploadDir . $filename;

                $fileModel = new AssetFileModel();
                $fileModel-&gt;sourceId = $this-&gt;assetSourceId;
                $fileModel-&gt;folderId = $this-&gt;assetFolderId;
                $fileModel-&gt;filename = IOHelper::getFileName($filename);
                $fileModel-&gt;kind = IOHelper::getFileKind(IOHelper::getExtension($filename));
                $fileModel-&gt;size = filesize($file);
                $fileModel-&gt;dateModified = IOHelper::getLastTimeModified($file);

                craft()-&gt;assets-&gt;storeFile($fileModel);

                // print_r($fileModel);

                // displaying file
                $image = array(
                    'url' =&gt; 'images/'.$filename,
                    'id' =&gt; 1
                );
                $this-&gt;returnJSON($image);
                exit;
            }
            else
            {
                $errors[] = "$filename was unable to be saved.";
            }
        }
    }

    $this-&gt;returnJSON(compact('errors'));
    exit;
}


}

How do I get my form to talk to it? Also, what else do I need to do to get it to work?
It doesn't seems possible natively, you should write a custom upload script.

→ Example #1

→ Example #2

If it doesn't matter to add the images inside your rich text field, one more simple workaround could be to allow image upload to your assets using a separate upload field.

→ Uploading Files from Front-end Entry Forms