The upload question type defines a file-select field and a 'Browse...' or 'Choose File' button for file uploads.
Syntax
By default, upload questions only accept image file types (.jpg, .png, etc.). Include the accept
tag to specify certain file types, or to allow a different form of media such as text or audio.
For a list of common file types, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types; or, for a complete list, see http://www.iana.org/assignments/media-types/media-types.xhtml.
Multiple types can be specified in a comma separated list format: media type followed by '/', extension type, comma, and repeat. You can also use the wildcard syntax * to allow any extension/file type.
Basic (accepts images only)
FILE. Upload your file:
type: upload
Specifying file types with 'accept' tag (any file extension type)
FILE. Upload your file:
type: upload
accept: text/*
Specifying file types with 'accept' tag (only png & jpg extension types)
FILE. Upload your file:
type: upload
accept: image/png,image/jpeg
Examples
Uploading a single file
In this question, respondents are allowed to upload any music file as the '*' specifies that all audio file types are permitted.
Specifying multiple file types
If multiple specific file types are required, they can be listed as a comma separated list with the accept
tag as shown below. In this example, by specifying both jpeg and png files, respondents will be initially prompted to upload png and jpeg files after clicking on the Choose File button.
Accessing uploaded files
Uploaded files are stored in the "upload" folder in the survey's File Manager applet. To access an image file called "FILE", use the following code. A max height and max width are used to normalize the display of potentially large images.
<img src="/upload/[* appid() *]/$QFILE" style="max-width: 1000px; max-height; 1000px;" />
Comments
0 comments
Please sign in to leave a comment.