Attaching documents to a questionnaire

 

Documents, images, media, and any file types can be attached to a questionnaire by uploading them from the respondent's computer, can be retrieved using a Data report, and can be sent as attachments by E-mail.

Creating a question to upload the attachment

To allow a questionnaire to upload a document, create a question and choose the Upload question style:

In the allowed extensions field, enter a list of the document extensions allowed, such as xls,xlsx,doc,docx separated by commas. A * can be used to allow any document type to be uploaded.
In the maximum file size field, enter the largest document size allowed.
Both of these parameters are important to prevent upload denial of service attacks.

File names must use only letters, numbers, dashes, hyphens and spaces. This default is configurable.

Respondent experience

These parameters will create a question that looks like this:

Upload question

The respondent uses the Browse button to find the worksheet, and then presses Upload. The document is uploaded, and the respondent sees a confirmation message:

The respondent can then can proceed to the next page of the questionnaire.

In all popular browsers, if the file extension is not allowed, or the file is larger than allowed, the user will be notified immediately rather than having to wait for the file to upload first.

Retrieving the data

When a document is uploaded, a unique identifying number is assigned to it. The original file name and the unique number are stored in the Upload question's field in the database. When the questionnaire data is retrieved using a Data report, responses that have an attached document include a clickable link with the original file name:

Clicking on the Attachment link will cause the document to be downloaded from the server and loaded with the application that is registered for that document's MIME type, such as Excel or Word.

The attachment link normally requires the user to be logged in to the ViewsFlash application. A new setting in the Data report uses a different URL for the link that makes the attachment available for download to anyone with the link, whether logged in to ViewsFlash or not.

Technical information

Configuring defaults with servlet parameters

The servlet parameter "upload.maxsize" limits the size of the largest document that can be uploaded. The default value is 10 million bytes.

When an upload form is presented to the user, there is a five minute timeout for uploading the form. After that, the uploaded file will not be accepted. The five minute timeout, in minutes, can be overridden with a servlet parameter: uploadtimeout=30

By default, only letters, numbers, spaces, underscore and dash are allowed in uploaded file names. File name checking is configured with the upload.strictfilename servlet parameter. The default value is 1, which allows only letters, numbers, space, underscore and dash. A value of 0 rejects file names that contain spaces. A value of 2 allows most characters, including Unicode, but still rejects file names with these characters: \/:*"<>|~&?*

Legacy behavior

As of release 7, ViewsFlash stores uploaded documents in the database by default, and no additional servlet parameters are needed.
To override this and to store documents in the file system as previous releases did, the system Administrator must include upload.method=file in the ViewsFlash servlet parameters. If a database is not being used, documents are also stored in the file system.

When upgrading from previous releases, including the upload.method=file servlet parameter will preserve the legacy behavior. If the parameter is omitted, all the documents saved in the file system will be migrated automatically to the database the first time that the application starts; note that the application might take a relatively long time to start.

If not using a database, the system Administrator must include the servlet parameter "upload.directory". If it is not specified,it defaults to /etc/cogix/upload. The upload.directory parameter must point to a directory where the ViewsFlash application server has been granted file creation, directory creation, and read, write and delete access rights. In a single-server deployment, any directory can be used. In a clustered deployment, this directory must reside on a shared volume, so that attachments gathered from all servers are stored in the same directory and can be accessed by all nodes in the cluster.

Uploaded files are stored in subdirectories named SSS!PPP, where SSS is the Place name and PPP is the questionnaire name.
The files are saved using names RRRRR.ext, where RRR is a random number and .ext is the original file extension.
The generated file name and the original file name are written to the Upload question's field in the database.


 

Next: Branching