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 URL associated with the file. |
| 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.
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.
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)
}