fileprompt
fileprompt Prompts the user for a file to be uploaded. It returns a cloudobject representing the new file. The cloudobject created will be of a special type called "storedCloudFile", with the following properties:
| Property | Description |
|---|---|
| url | The address of the file's bytes. It serves them only to the session the object was handed to (a device that received the object, through a cloud set or a variable), so a copied address, or one with another id, opens nothing. It is not a link for outsiders: to give the file to someone else, attach it to a mail with send_mail. |
| original_filename | The file's original file name (with extension) |
| last_modified_time | Unix time stamp of the last modified time for the file. |
| size | Size of the file in bytes. |
| extension | The file's extension (e.g. "pdf") |
| mime_type | The MIME type string for the file (e.g. "application/pdf") |
If the user selects "cancel" then fileprompt will return FALSE. If fileprompt 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 files stored on the mobile device.
Access is per session
The file's url works only for the session the object was handed to: the server records, for each session, the stored files 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. A url read on the server side (in an activity composing a mail) carries no session and opens nothing: send the file as an attachment of send_mail instead, or make an address for an outsider with public_link.
Uploaded file data will be stored in the database
Despite the fact the there are URLs for the stored files, the actual uploaded data will be stored in the application database, and will be removed from the database if the storedCloudFile is deleted using the delete() function.
Format:
file_object = fileprompt()
Parameters:
This function does not take any parameters.
Returned Value:
| Type | Description |
|---|---|
| cloudobject | The storedCloudFile created (or FALSE if cancelled or upload failed) |
Examples
document = fileprompt()
if (upload_error) {
alert(upload_error)
}