angularjs - k-file-error when kendo upload is successfull -
i manage upload files kendo , angularjs, files remain red , have k-file-error class, files uploaded , can have them on back. why there error ? please me ?
<div class="demo-section k-content"> <div> <h4>upload files</h4> <div class="dropzoneelement">drag , drop file here</div> <input name="files" ng-model="vm.files" type="file" kendo-upload k-async="{ saveurl: 'http://localhost:5000/api/upload/', removeurl: 'remove', autoupload: true, withcredentials: false }" k-select="onselect" k-upload="onupload" k-progress="onprogress" k-success="onsuccess" options="vm.options" /> </div> <button ng-click="vm.test()">test</button> </div> class documentcontroller { /* @nginject */ constructor($scope, authtokenservice) { this.name = 'document'; $scope.onselect = e => { // console.log(e.files); }; $scope.onupload = e => { const token = authtokenservice.gettoken(); // check if token expire if (token && authtokenservice.isexpired(token)) { authtokenservice.settoken(); } const xhr = e.xmlhttprequest; if (xhr) { xhr.addeventlistener('readystatechange', () => { if (xhr.readystate === 1) { // add token header if (token) { xhr.setrequestheader('authorization', `bearer ${token}`); } } }); } }; $scope.onsuccess = e => { console.log(e); }; $scope.onprogress = e => { // console.log(e); }; this.options = { dropzone: '.dropzoneelement' }; } } export default documentcontroller;
you should return valid json result server response. return json(true)
should work.
Comments
Post a Comment