Changing the Behaviour of a File Uploader

Change the behaviour of a file uploader’s default settings by altering the automatically assigned three Parameter Attributes, and adding additional attributes.

Implementation:

  1. Switch to the Definition tab.
  2. Select the File Uploader question in your model.
  3. Expand it to see the default settings of the question's Parameter Attributes.
  4. Right-click the intended question.
  5. Click Attributes.
  6. In the Model Item Attributes window select each of the parameters, one at a time, switch to the Value panel, and change the default Parameter Value for the following:
Parameter Name Description
MaxNumberOfFiles

Limits the total number of files that can be uploaded in the current session. If the user attempts to upload any more than this, a message will tell them they have reached the limit, and the additional file will not be uploaded until one or more are removed. By default, the limit is 10.

MaxFileSizeKB

Determines the maximum size of any single uploaded file, in kilobytes. By default, this is set to 10240 (10MB).

AllowedFileFormats

This parameter must be assigned a comma-separated list of file extensions. If the user attempts to upload a file whose extension is not in this list, they will be prevented from doing so. By default, this parameter uses the following list of extensions:

jpeg, jpg, gif, png, zip, doc, docx, rtf, pdf

For a user to be able to upload photos taken by their device, the file uploader must be configured to accept JPEG files.

  1. (Optional) Add the following parameter attributes to make further customisations to your file uploader question:
Parameter Name Description
ModelVariable

This parameter can be used if you want to save a comma-separated list of all uploaded files in a variable. Use the name of the intended variable as the parameter's value.

Refresh

This parameter can be used to determine if a postback will occur when the upload button is clicked. Uploaders are set to refresh by default, so you only need to create this parameter if you want to turn the postback off, which you can do by setting the parameter value to False.

ShowList

This parameter can be used to display a list of all files that have been uploaded with the question in the current session. To do this, set the parameter value to True.

The mobile version of the file uploader will list each uploaded file on-screen, with a tick symbol to indicate that a particular file has been uploaded. For this reason, ShowList will have no effect on mobile applications.

  1. Click OK.

File data uploaded to the current session will be lost when the session ends (for example, if the current browser window is closed). While it still exists, there are a number of tasks that can be performed using the session data, all of which are achieved using the WithUploadedItems function.