jFormer Documentation → Basic Fields →
JFormComponentFile(String id, String label[, Array optionArray])
The File field type allows users to select files from their computer to be uploaded on form submission.
new JFormComponentFile(String id, String label[, Array optionArray])
Create a simple file component:
$file = new JFormComponentFile('id', 'Label:');
Array, [name, type, tmp_name, error, size(in bytes)]
.jFormComponentFile
These options are common to all components.
null
HTML | a description for the component, shows underneath the component inside a DIV with the class jFormComponenpescription.
null
Array, [max(int), addButtonText(string), removeButtonText(text)] | see instanceOptions page for more information.
null
Array, [dependentOn(string), display(string), jsFunction(Javascript)[, animationOptions(array)]] | see dependencyOptions page for more information.
null
HTML | a tooltip that displays whenever the component has focus. Gives any extra help or explanation a form user might need.
null
Array | an of validations specific to the component, see the specific component for its validations.
false
Boolean | this option makes the error tip only show up on the first focus on the component if it does not pass validation.
false
Boolean | if true pressing enter while this component has focus submits the form, or advances to the next page.
null
CSS | set the style attribute for the component wrapper div.
null
String | preset the value of the component upon form loading.
| Name | Error Message and Description |
| required |
"Required." The 'required' validation checks to make sure the component has a value.
'validationOptions' => array('required'),
In some cases, you may wish to use 'matches' in a setting where there can be more than one instance of a section that contains both the original field and the field you want to match against. In this case, 'matches' must be assigned to an associate array that contains two keys. The first key, 'matches' receives an HTML ID (without the #) of the particular field that you wish to match a value against. The second key, 'sectionInstances' receives a boolean indicating whether or not the value you want to match against is a member of a section that can have more than one instance. For example:
'validationOptions' => array(
'matches' => array(
'matches' => 'password',
'sectionInstances' => true
)
),
|
| extension |
"Must have the 'user defined' extension." The 'extension' validation takes a value a determined extension and checks to make sure the file selected has that extension.
'validationOptions' => array('extension' => 'txt'),
|
| extensionType |
"Incorrect file type." The 'extensionType' validation makes sure the file selected is of the correct type, types are:
'validationOptions' => array('extensionType' => 'image'),
|
| size |
"File must be smaller then [sizelimit]kb. File is [filesize]kb." The 'size' validation takes a integer and checks it against the file size (in kb) of the uploaded file (server side only).
'validationOptions' => array('size' => 1024),
|
| imageDimensions |
if file is not am image: "File is not a valid image file." if image is larger than dimensions given: "Image must be less then [width]px wide. File is [imagesize]px." "Image must be less then [height]px tall. File is [imagesize]px." The 'imageDimensions' validation takes an array with keys of 'width' and 'height' and checks the image size against these values.(server side only)
'validationOptions' => array('imageDimensions' => array('width' => 800, 'height' => 600)),
|
| minImageDimensions |
if file is not am image: "File is not a valid image file." if image is smaller than dimensions given: "Image must be more then [width]px wide. File is [imagesize]px." "Image must be more then [height]px tall. File is [imagesize]px." The 'minImageDimensions' validation takes an array with keys of 'width' and 'height' and checks the image size against these values.(server side only)
'validationOptions' => array('minImageDimensions' => array('width' => 800, 'height' => 600)),
|
Next Page: Hidden
This page was last edited on April 11, 2011 at 3:14pm.
3 comments (add a comment)
LAGRANGE on 2011-07-21 06:32:58
The input file don't works with the google chrome browser !
LAGRANGE on 2011-07-21 06:34:16
The input file don't works with the google chrome browser !
Two notes:
1.It works in Chrome and Opera. You have to set parameter
'customStyle'=>false
in Options array
2. Value returned is object. Not array!
Hope it helps somebody.