Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I am trying to post a field data with a file (posted as array of bytes in the data base as shown in the figure) and tried this comment comment

but I see the uploaded fields are encapsulated one more step in to object called fied how can I exactly do a post with params id,fname

here is how the Api API to upload the data

can you please comment my code

    $scope.$watch('files', function () {
        $scope.upload($scope.files);
    });

    $scope.upload = function (files) {
        if (files && files.length) {
            for (var i = 0; i < files.length; i++) {
                var file = files[i];
                Upload.upload({
                    url: 'https://angular-file-upload-cors-srv.appspot.com/upload',
                    fields: {
                        'Id': 23,
                        'fname':'name'
                    },
                    file: file
                }).progress(function (evt) {
                    var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
                    console.log('progress: ' + progressPercentage + '% ' + evt.config.file.name);
                }).success(function (data, status, headers, config) {
                    console.log('file ' + config.file.name + 'uploaded. Response: ' + data);
                }).error(function (data, status, headers, config) {
                    console.log('error status: ' + status);
                })
            }
        }
    };

Here the console display from the inspection

the response data when JSON.stringify called looks like

file: Capture.PNG, Response: {"result":[{"fieldName":"Id","value":"23"},{"fieldName":"fname","value":"name"},{"fieldName":"file","name":"Capture.PNG","size":"156273"}],"requestHeaders":{"Host":"angular-file-upload-cors-srv.appspot.com","Accept":"application/json, text/plain, /","Accept-Language":"en-US,en;q=0.8","Content-Length":"156644","Content-Type":"multipart/form-data; boundary=----WebKitFormBoundaryrU857yqmqVnWHbFD","origin":"http://fiddle.jshell.net","Referer":"http://fiddle.jshell.net/_display/","User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36","X-AppEngine-Country":"ET","X-AppEngine-Region":"?","X-AppEngine-City":"addis ababa","X-AppEngine-CityLatLong":"9.022736,38.746799"}}

enter image description here

share|improve this question
    
It seems that your problem lies on server-side. Can you tell me what technology are you using at your server? – Lajos Arpad Jul 25 at 10:56
    
Web api that works fine so far and mysql backend ,I am not sure this module is fine for can you suggest – Dagm Fekadu Jul 25 at 10:57
    
this module --> ngFileUpload module at github.com/danialfarid/ng-file-upload – Dagm Fekadu Jul 25 at 10:59
    
You should convert the upload parameters into json and take a look at them. If you could give me the json, I would be able to tell you what you need to do. – Lajos Arpad Jul 25 at 11:13
    
See the edit,I have added response json stringify output on the consol – Dagm Fekadu Jul 25 at 11:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.