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
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"}}