Custom Previews for File Upload Questions
SurveyJS File Upload questions support the file preview functionality out of the box (see the File Upload demo). This example demonstrates how you can override this functionality and implement custom file previews if required. Read more...
SurveyJS File Upload questions support the file preview functionality out of the box (see the File Upload demo). This example demonstrates how you can override this functionality and implement custom file previews if required.
To implement custom file previews, follow the steps below:
Disable built-in file previews.
Set the File Upload question'sshowPreview
property tofalse
.Render a custom preview.
ImplementSurveyModel
'sonAfterRenderQuestion
event handler to modify the File Upload question markup using JavaScript. In this demo, the event handler adds a<div>
element to the bottom of the question. When users select one or multiple files for upload, this<div>
displays "Download file" and "Remove file" buttons per uploaded file.
In this demo, files are uploaded to SurveyJS servers from where they are then deleted after a predefined period of time. We strongly encourage you to use your own servers for file uploads when you use SurveyJS to collect sensitive respondent data in your application.