ionic-surveyjs
ionic-surveyjs copied to clipboard
surveyjs question type upload is not working
Hi, did you ever tested a survey with a question type upload ?
The input field of type "file" is rendered in the ionic app (android and ios), it opens a filemanager but chosen image is not uploaded to surveyjs backend.
I think that the angular component Survey (from 'survey-angular') is not suited for an hybrid app.
File upload in ionic should be done using a cordova plugin file transfer see https://ionicframework.com/docs/native/file-transfer/
Do you think it is possible override existing Javascript function in 'survey-angular.js' ?
dxSurveyService.prototype.sendFile = function (postId, file, onSendFile) {
var xhr = new XMLHttpRequest();
xhr.onload = xhr.onerror = function () {
if (!onSendFile)
return;
onSendFile(xhr.status == 200, JSON.parse(xhr.response));
};
xhr.open("POST", dxSurveyService.serviceUrl + '/upload/', true);
var formData = new FormData();
formData.append("file", file);
formData.append("postId", postId);
xhr.send(formData);
};