Question T6745
Visible to All Users

Is there any Option to save Image and all Content file save in our server instead of Byte?

created 4 years ago

Hello Team,

Right now i stuck at one problem in creator Library. I used Image option tool and upload my local image for crete Survey it is save in Bytes in array.

So when i reopen cretor from same Json is too large and not able to stringify.

So any option to save path in local machine and Use that path in Cretor and Survey View?

Thanks

Answers approved by surveyjs Support

created 4 years ago

Hello,

SurveyJS Creator has the onUploadFile event for this purpose.
You can use the following code (as we're using on our site):

JavaScript
creator.onUploadFile.add(function(creator, options) { var formData = new FormData(); formData.append("Id", modelData.Id); options.files.forEach(function(file) { formData.append(file.name, file); }); $.ajax({ url: baseUrl + "uploadFiles?accessKey=" + accessKey, type: "POST", xhr: function () { var myXhr = $.ajaxSettings.xhr(); if (myXhr.upload) { myXhr.upload.addEventListener('progress', function (event) { var percent = 0; var position = event.loaded || event.position; var total = event.total; }, false); } return myXhr; }, success: function (data) { options.callback("success", baseUrl + "files?name=" + data[options.files[0].name]); }, error: function (error) { }, async: true, data: formData, cache: false, contentType: false, processData: false, timeout: 60000 }); });

Thanks, Serge
SurveyJS Team