Manage Image Uploads
When survey authors design a form or questionnaire, they can add images to use as a survey logo or background, in the survey header, or within Image and Image Picker questions. Those images are embedded in the survey and theme JSON schemas as Base64 URLs. However, this technique increases the schema size. To avoid this, you can upload images to a server and save only image links in the JSON schemas, as shown in this demo.
To implement image upload, handle the onUploadFile
event. Its options.files
parameter stores the images you should send to your server. Once the server responds with an image link, call the options.callback(status, imageLink)
method. Pass "success"
as the status
parameter and a link to the uploaded image as the imageLink
parameter.
In this demo, images 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 image uploads when you use SurveyJS to collect sensitive respondent data in your application.