Skip to main content

Image Upload

Allows for image file uploads with preview and validation.

Examples

Basic Example

The following example demonstrate some of the available functionality for read_image

from abstra.forms import read_image

file_response = read_image("Upload your .png image")
file = file_response.file # File object

Parameters

NameDescriptionType
labelThe label to display to the userstr
initial_valueThe initial value to display to the user. Defaults to "".str
multipleWhether the user will be allowed to upload multiple files. Defaults to False.bool
max_file_sizeMaximum size allowed to be transfered in total in MB.float
disabledwhether the input is disabled. Defaults to False.bool
requiredWhether the input is required or not eg. "this field is required". Defaults to True.Union[bool, str]
hintA tooltip displayed to the user. Defaults to None.str
end_programWhether the program should end after the widget is shown. Defaults to False.bool
full_widthWhether the input should use full screen width. Defaults to False.bool
button_textWhat text to display on the button when the widget is not part of a Page. Defaults to 'Next'.str

Return Values

TypeDescription
Union[FileResponse, List[FileResponse]]A dict containing the image file uploaded by the user ({"file": file, "url": str, "content": bytes}) or a list of images in case of multiple flag set as True