imageprompt
imageprompt
Prompts the user for an image to be uploaded. It returns a cloudobject representing the new image
the app will automatically process the image into three resolutions: the original, a "mid size" image, and a "thumbnail" image.
The cloudobject created will be of a special type called "storedCloudImage",
whose "url", "midsize_url" and "thumbnail_url" will be the URLs associated with the full size, mid size and thumbnail sized images.
These addresses serve the image only to the session the object was handed to (see the note on access below).
If the user selects "cancel" then imageprompt will return FALSE.
If imageprompt encounters an error, then it will return FALSE, an alert will be shown
describing the error and the global variable
"upload_error" will be set to the string describing the error.
Runs on: either side: the compiler places the statement that calls it where the values it uses live.
The Prompt may vary
The actual prompt displayed on the user's screen may vary depending on the type of device. On some mobile devices, a button may appear that, when clicked, will give the user options for using existing images stored on the mobile device, or to take a new photo using the camera.
Access is per session
The three urls work only for the session the object was handed to: the server records, for each session, the stored images it sent to that device, and serves the bytes to that session alone (since November 2026). The address a device receives carries a token of that session, and the token is the whole check: an address with another id or without the token is refused, but the address works for whoever holds it while that session lives, so never store it in a field or send it on (hand another user the object itself, in a field of a record they receive). Show an uploaded image from the object's fields (an item template's {{thumbnail_url}}, an image element bound to the variable), never by copying its address into the design; a url read on the server side carries no session and opens nothing. For someone outside the app (a link in a mail), make an address with public_link.
Uploaded image data will be stored in the database
Despite the fact the there are URLs for the stored images, the actual uploaded image data will be stored int he application database, and will be removed form the database if the storedCloudImage is deleted using the delete() function.
Format:
image = imageprompt()
Parameters:
This function does not take any parameters.
Returned Value:
| Type | Description |
|---|---|
| cloudobject | the storedCloudImage created (or FALSE if cancelled or upload failed) |
Examples
profile_image = imageprompt()
if (upload_error) {
alert(upload_error)
}