This input gives you to choose files from ImpressPages repository. This is recommended and easiest way to upload files in admin. This field doesn't work for your website visitors because the repository is accessible only for administrators. If this field doesn't work, please make sure your form has environment set to admin.

Usage example 

$form = new \Ip\Form();
$values = array();
$form->addField(new \Ip\Form\Field\RepositoryFile(
        'name' => 'someName',
        'label' => 'Anything you like',
        'preview' => 'thumbnails', //or list. This defines how files have to be displayed in the repository browser
        'value' => $values, //optional. Already uploaded files if this is the form to update already existing record
        'fileLimit' => 10, //optional. Limit file count that can be selected. -1 For unlimited
        'filterExtensions' => array('jpg', 'jpeg', 'png') //optional
echo $form->render();

 In controller, where this form is submitted you will get an array of selected file names relative to file/repository or file/secure directories. Use following code to get an URL to image

ipFileUrl('file/repository/' . $submittedValue);

Also you can use ipReflection() function to get cropped image (if uploaded file was an image). 

secure option most often is set to false or skipped as often you use standard repository where all files are accessible by link in the browser. All gallery files, etc. counts to it. You have to set secure to true only if you are creating downloadable product plugin where administrator has to upload file that has to be NOT accessible using a browser.

Advanced options

Option Default value Comment
path null Set a sub-directory to be open instead of the repository rootdirectory. E.g. if you have a folder file/repository/mycustomdir, user 'path' => 'mycustomdir/' option. Useful in some specific plugins when all related files are stored in a subdirectory. Available since 4.5.3.
secure false Set to true if you want to select files from file/secure folder instead of the default repository dir (file/repository)

JavaScript events

This field type triggers following JavaScript events:

  • ipFieldFileAdded (second parameter of an event is the file name added)
  • ipFieldFileRemoved


    $('.form-group.type-repositoryFile').on('ipFieldFileAdded', function (e, fileName) {
comments powered by Disqus