1

I am using kendo to upload files from the client everything is working as expected while loading , But here i have question related to url when we upload files i am using url in the config when file loads succesfully i have response from the server.

How can i extract data from response using kendo async saveUrl method ?

main.html

<div class="form-group col-md-6">
    <div class="col-md-6">
        <label for="prcFileUploadField">File:</label>
    </div>
    <div class="col-md-6">
        <input name="file" type="file" kendo-upload="fileAttachment" k-upload="addMorePostParameters" k-success="onSuccess" k-error="onError" k-options="fileAttachmentOptions" k-select="onSelect" k-remove="onUploadRemove" />
    </div>
</div>

ctrl.js

angular.module('App').controller('PrcUploadCtrl',function($scope,$timeout,$rootScope,prcUploadConfig){
    'use strict';
    var fileData = [];
    $scope.fileAttachmentOptions = prcUploadConfig.fileAttachmentConfig;

    $scope.prcUploadGridOptions = prcUploadConfig.getPrcUploadDataGrid;
    prcUploadConfig.getPrcUploadDataGrid.dataSource='';

    $scope.onSelect = function (e) {
        fileData = e.files;
        var message = $.map(e.files, function(file) { return file.name; }).join(", ");
        console.log(message);
        console.log(JSON.stringify(fileData));
    };

    //if error 
    $scope.onError = function() {
        console.log("loggin error");
        $timeout(function () {
            var filesToBeRemoved = $scope.fileAttachment.wrapper.find('.k-file');
            $scope.fileAttachment._removeFileEntry(filesToBeRemoved);
        },5000);
    }
});

config.js

fileAttachmentConfig: {
  async: {
      saveUrl: 'app/upload/uploadAttch',
      removeUrl: 'remove',
      removeVerb: 'DELETE',
      autoUpload: false
  },
  template: '<span class=\'file-name-heading\'>Name:</span> <span>#=name#</span><button type=\'button\' class=\'k-upload-action\'></button>'
}

1 Answer 1

2

You can always get a response body from successful requests like this:

$scope.onSuccess = function(e) {
    var response = e.response;
    //...
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer i can see response now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.