Jet\Form_Field_FileImage / Form_Field::TYPE_FILE_IMAGE

Represents a form field for uploading an image or images.

The Jet\Form_Renderer_Field_Input_File renderer is used to display the form field itself.

Výchozí chybové kódy

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 a type enabled, so it is not a supported image.

Parameters

Parameter Type Required Meaning of
allowed_mime_types (array) array no List of allowed MIME file types.

The default value is determined using the Jet\Data_Image::getSupportedMimeTypes() method, but it is possible to set your own value.
maximal_file_size (int) int no Maximum file size in bytes.
allow_multiple_upload bool no Uploading multiple files at once is/is not allowed.
maximal_width int no Maximum image width - if the uploaded image exceeds it, it will be automatically reduced to the given size.
maximal_height int no Maximum image height - if the uploaded image exceeds this, it will be automatically reduced to the given size.

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 setMaximalSize(
int $maximal_width,
int $maximal_height
)
Sets the maximum allowed image size. If the image exceeds these dimensions, it is automatically scaled down to fit within the limit. Aspect ratios are preserved.
public getMaximalHeight(
) : int|null
Returns the set maximum height.
public getMaximalWidth(
) : int|null
Returns the set maximum width.
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 of uploaded files.

The values are already preset, but it is of course possible to change the settings.
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.
Previous chapter
Jet\Form_Field_File_UploadedFile
Next chapter
Select options