select files, generated dynamic file selector


This control reads the contents (file and directory entries) of a directory and creates a select of the items found. Some examples:

  1. Directory tree containing only files, with relative paths:
  2. Directory tree containing only files, with absolute paths:
  3. Directory tree containing only directories, with relative paths:

There are many options to customize apperance and behaviour like file inclusion/exclusion, display format, recursive traversal settings.


= Array(

'id' => Array(

'type'          => 'selectFile',
'displayname'   => 'Please select a file',

'directory'     => '/home/www/',
'tree'          => 0// default: 1
'includedirs'   => 0// default: 0
'includefiles'  => 0// default: 1

    // exclusion of specific files:
'exclude'       => Array( 'autoexec.bat''config.sys' ), 
// exlusion using regular expression (preg_match compatible string):
'excludere'     => '/\.txt$/i'// matching files will be discarded
    // inclusion using regular expression (preg_match compatible string)
'includere'     => '/\.xls$/i'// matching files will be included
    // ordering the files in the list
'order'         => 'name'// default: empty (unordered, as-is)
    // ordering options: name, namedesc, size, sizedesc

    // display format string (sprintf style) for regular files
'format'        => '%1$s (%2$d bytes)',
// %1$s means filename, %2$d is the size

    // display format string (sprintf style) for directories
'formatdir'     => '%1$s',    
// %1$s is the filename, %2$d is the size (omitted by default for dirs)

    // show directory paths in filename
'fullpath'      => 0// default: 0

    // include directory path in returned value
'fullpathvalue' => 0// default: 0

    // should directory names end with /
'trailingslash' => 0// default: 1

'values'        => 
'/home/www/' => 'Your home directory'
'value'         => '/home/www/',

'html'           => 'class="inputfieldstyle"',
'help'           => 'validation failed for this element',
'rowlayout'      => '...%element% %prefix% %postfix% etc...',
'prefix'         => 'string to display before element',
'postfix'        => 'string to display after element',
'readonly'       => 0,
'display'        => 0,
'htmlid'         => 'name1',




Live examples:

Validators to use together with this element:

form validation for developers!

clonefish is a proven, mature form generator class that helps PHP developers to create, validate and process secure, flexible and easy-to-maintain forms
learn more
Bookmark and Share