Question T17285
Visible to All Users

How to Add storeDataAsText to false using designer while creating a survey form

created 10 months ago

want to do file upload but not to get file content as base64 so trying to do the onFileupload Method for that i need this storeDataAsText how to do this in designer

Answers approved by surveyjs Support

created 10 months ago

Hello,
By default, the File question's storeDataAsText property is unavailable in a SurveyJS Creator because it is required to attach the survey.onUploadFiles function.
If you wish to upload files to a server and allow users configure this in a survey creator, please follow these steps:

JavaScript
import { Serializer } from "survey-core"; Serializer.getProperty("file", "storeDataAsText").visible = true;
  • Now, to allow a survey to upload files to a specified storage, implement the SurveyModel's onUploadFiles event and upload files to a specified storage. In a survey creator, you can access the previewed survey using the creator.onSurveyInstanceCreated function.
JavaScript
creator.onSurveyInstanceCreated.add((sender, options) => { if(options.reason === 'test'){ const survey = options.survey; survey.onUploadFiles.add(() => { //... }); } });

Please let me know if you have any further questions.