Jet\Form_Field_File / Form_Field::TYPE_FILE
Represents a form field for uploading a file, or files, of any type.
The Jet\Form_Renderer_Field_Input_File renderer is used to display the form field itself.
Default error codes
| Code | Meaning of |
|---|---|
| Form_Field::ERROR_CODE_EMPTY | The field is marked as required and the value is not specified - the file is not selected. |
| Form_Field::ERROR_CODE_FILE_IS_TOO_LARGE | The file is too large - its size exceeds the set limit. |
| Form_Field::ERROR_CODE_DISALLOWED_FILE_TYPE | The file does not have an allowed type - if the restriction on allowed file types is set.s |
Parameters
| Parameter | Type | Required | Meaning of |
|---|---|---|---|
| allowed_mime_types | array | no | List of allowed MIME file types. |
| maximal_file_size | int | ne | Maximum file size in bytes. |
| allow_multiple_upload | bool | ne | Uploading multiple files at once is/is not allowed. |
Methods
| Method | Meaning of |
|---|---|
| public getMaximalFileSize( ) : int|null |
Returns the set maximum file size in bytes of the uploaded file. |
| public setMaximalFileSize( int|null $maximal_file_size ) : void |
Sets the maximum size of the file to be uploaded in bytes. |
| public getAllowedMimeTypes( ) : array |
Returns a configured list of allowed MIME types for uploaded files. |
| public setAllowedMimeTypes( array $allowed_mime_types ) : void |
Sets the list of allowed MIME types for uploaded files. |
| public getAllowMultipleUpload( ) : bool |
Indicates whether or not multiple files are allowed to be uploaded at once. |
| public setAllowMultipleUpload( bool $allow_multiple_upload ) : void |
Enables/disables uploading multiple files at once. |
| public getAllFiles( ) : Form_Field_File_UploadedFile[] |
Returns a list of all captured uploads, whether they pass validation or not. |
| public getValidFiles( ) : Form_Field_File_UploadedFile[] |
.Returns a list of those captured uploads that passed validation. |
| public getValue( ) : Form_Field_File_UploadedFile[] |
Returns a list of those captured uploads that passed validation. |
| public getProblematicFiles( ) : Form_Field_File_UploadedFile[] |
Returns a list of those captured uploads that failed validation. |