class FileManager (View source)

Methods

string
file(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a file.

string
image(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick an image file.

string
video(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a video file.

string
text(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a text file.

string
audio(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick an audio file.

string
doc(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a document file.

string
app(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a application file.

string
fileOfType(int $type, string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a file of a specific type.

Details

string file(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a file.

Parameters

string $inputID

The ID of the form field – NOTE this is no longer used but remains for backward compatibility.

string $inputName

The name of the form field (the selected file ID will be posted with this name)

string $chooseText

The text to be used to tell users "Choose a File"

File|Version|int|null $preselectedFile

the pre-selected file (or its ID)

array $args

An array with additional arguments. Supported array keys are:

  • ```'filters'```
    A list of file filters. Every array item must have a 'field' key (with the name of the field as the value), and another field that's specific of the field.
    For a list of valid field identifiers, see the definition of the loadDataFromRequest method of the classes that implement \ Concrete\Core\Search\Field\FieldInterface (usually it's the requestVariables property).
A list of arrays. Each array item must have a 'field' key whose value is the name of the field, and

Return Value

string $html

Examples

<code><pre>
$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$filemanager = $app->make(\Concrete\Core\Application\Service\FileManager::class);
echo $filemanager->file(
    'myId',
    'myName',
    t('Choose File'),
    $preselectedFile,
    [
        'filters' => [
            [
                'field' => 'type',
                'type' => \Concrete\Core\File\Type\Type::T_IMAGE,
            ],
            [
                'field' => 'extension',
                'extension' => ['.png', '.jpg'],
            ],
        ],
    ]
)
</pre></code>

string image(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick an image file.

Parameters

string $inputID

The ID of the form field

string $inputName

The name of the form field (the selected file ID will be posted with this name)

string $chooseText

The text to be used to tell users "Choose a File"

File|Version|int|null $preselectedFile

the pre-selected file (or its ID)

array $args

See the $args description of the file method

Return Value

string $html

See also

FileManager::file

string video(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a video file.

Parameters

string $inputID

The ID of the form field

string $inputName

The name of the form field (the selected file ID will be posted with this name)

string $chooseText

The text to be used to tell users "Choose a File"

File|Version|int|null $preselectedFile

the pre-selected file (or its ID)

array $args

See the $args description of the file method

Return Value

string $html

See also

FileManager::file

string text(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a text file.

Parameters

string $inputID

The ID of your form field

string $inputName

The name of the form field (the selected file ID will be posted with this name)

string $chooseText

The text to be used to tell users "Choose a File"

File|Version|int|null $preselectedFile

the pre-selected file (or its ID)

array $args

See the $args description of the file method

Return Value

string $html

See also

FileManager::file

string audio(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick an audio file.

Parameters

string $inputID

The ID of your form field

string $inputName

The name of the form field (the selected file ID will be posted with this name)

string $chooseText

The text to be used to tell users "Choose a File"

File|Version|int|null $preselectedFile

the pre-selected file (or its ID)

array $args

See the $args description of the file method

Return Value

string $html

See also

FileManager::file

string doc(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a document file.

Parameters

string $inputID

The ID of your form field

string $inputName

The name of the form field (the selected file ID will be posted with this name)

string $chooseText

The text to be used to tell users "Choose a File"

File|Version|int|null $preselectedFile

the pre-selected file (or its ID)

array $args

See the $args description of the file method

Return Value

string $html

See also

FileManager::file

string app(string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a application file.

Parameters

string $inputID

The ID of your form field

string $inputName

The name of the form field (the selected file ID will be posted with this name)

string $chooseText

The text to be used to tell users "Choose a File"

File|Version|int|null $preselectedFile

the pre-selected file (or its ID)

array $args

See the $args description of the file method

Return Value

string $html

See also

FileManager::file

private string fileOfType(int $type, string $inputID, string $inputName, string $chooseText, File|Version|int|null $preselectedFile = null, array $args = [])

Sets up a form field to let users pick a file of a specific type.

Parameters

int $type

One of the \Concrete\Core\File\Type\Type::T_... constants.

string $inputID

The ID of your form field

string $inputName

The name of the form field (the selected file ID will be posted with this name)

string $chooseText

The text to be used to tell users "Choose a File"

File|Version|int|null $preselectedFile

the pre-selected file (or its ID)

array $args

See the $args description of the file method

Return Value

string

See also

FileManager::file