Redactor / Documentation / Settings

Files

fileUpload #

Sets path URL to the file upload script.

$('#redactor').redactor({
    fileUpload: '/myadmin/files/upload/'
});

File will be transmitted in FILES array, for example, in PHP:

$_FILES['file']

By default, variable name is 'file', but this can be changed using fileUploadParam.

File script must return a JSON string in following format in order for a file to be inserted into Redactor as a link:

{
    "url": "/files/file.pdf",
    “name”: "My PDF file"
	"id": "1",
}

Both filelink and filename parameters are required.

In PHP, such string can be created like this:

$array = array(
    "url" => "/tmp/files/file.pdf",
    "name": "My PDF file"
	"id": "1",
);

echo stripslashes(json_encode($array));

fileUploadParam #

This setting allows to change default name ('file') for fileUpload variable.

$('#redactor').redactor({
    fileUpload: '/myadmin/files/upload/',
    fileUploadParam: 'my-name'
});

In this example, imageUpload variable name will be 'my-name' and it can be retrieved like this (in PHP):

$_FILES['my-name']

dragFileUpload #

Set to 'true' by default.

Turns off the ability to upload files using drag and drop:

$('#redactor').redactor({
    dragFileUpload: false
});

fileUploadFields #

This setting allows to pass data from selected fields with file uploads. This setting requires element field's selector, for example, '#my-field', or multiple selectors, for example, '#my-field-1', '#my-field-2', or a class '.my-fileds'

$('#redactor').redactor({
	fileUpload: 'http://site.com/upload/',
	fileUploadFields: '#my-field'
})

fileUploadForms #

This setting allows to pass data from selected form along with a file on upload. This setting requires form's selector, for example, '#my-form', or multiple selectors, for example, '#my-form-1', '#my-form-2', or a class '.my-form'

$('#redactor').redactor({
	fileUpload: 'http://site.com/upload/',
	fileUploadForms: '#my-form'
})