File
Elements
The XFL file element validates file input fields. For example to ensure an upload is no large than 100Kb.
Dissection of the XFL File Element
Syntax
Attributes
| Attribute | Value | Description | Required |
|---|---|---|---|
| type | method name | method to execute in the XFL_File class | ![]() |
| value | text | value to pass to the method | ![]() |
| select | XPath query | XPath query to retrive a value from data (post or population data) | ![]() |
| error | text | error to add to stack if method returns false | ![]() |
Processing Information
XFL File elements will execute the method defined in the type attribute in the XFL_File class. Custom file validators can be created by adding new methods to the XFL_File class.
Built-in Functions
XFL comes with the following file validators built in.
mime
The mime validator will check if an uploaded file has a defined mime type or types.
Example:
Outcome:
The file will pass validation if a png file was uploaded.
minFileSize
The minFileSize validator will check if an uploaded file is at least a specified size (in bytes).
Example:
Outcome:
The file will pass validation if a file at least 100,000 bytes was uploaded.
maxFileSize
The maxFileSize validator will check if an uploaded file is no more than a specified size (in bytes).
Example:
Outcome:
The file will pass validation if a file no more than 100,000 bytes was uploaded.
imgWidth
The imgWidth validator will check if an uploaded file is an image with a specified width (in pixels).
Example:
Outcome:
The file will pass validation if it is an image with a width of 48 pixels.
imgHeight
The imgHeight validator will check if an uploaded file is an image with a specified height (in pixels).
Example:
Outcome:
The file will pass validation if it is an image with a height of 48 pixels.
minImgHeight
The minImgHeight validator will check if an uploaded file is an image with a height more than or equal to the specified height (in pixels).
Example:
Outcome:
The file will pass validation if it is an image with a height of at least 48 pixels.
maxImgHeight
The maxImgHeight validator will check if an uploaded file is an image with a height less than or equal to the specified height (in pixels).
Example:
Outcome:
The file will pass validation if it is an image with a height of at most 48 pixels.
minImgWidth
The minImgWidth validator will check if an uploaded file is an image with a width more than or equal to the specified width (in pixels).
Example:
Outcome:
The file will pass validation if it is an image with a width of at least 48 pixels.
maxImgWidth
The maxImgWidth validator will check if an uploaded file is an image with a width less than or equal to the specified width (in pixels).
Example:
Outcome:
The file will pass validation if it is an image with of at most 48 pixels.

