i am using backbone for views,bootstrap and back end as spring rest web services. I want to upload a file from from backbone view to server using spring rest webservices. Any references??
Asked
Active
Viewed 783 times
1
-
see this [link](https://spring.io/guides/gs/consuming-rest-backbone/). i hope meet your answer – Virendra Nagda Nov 25 '15 at 12:13
1 Answers
0
Modern browsers are capable of uploading files via AJAX while older browsers are not. If you need to support IE < 10 you will probably need to implement a form+iframe based solution.
var formData = new FormData();
formData.append('file', $('#file')[0].files[0]);
$.ajax({
url: '/rest/endpoint',
type: 'POST',
enctype: 'multipart/form-data',
processData: false, // tell jQuery not to process the data
contentType: false, // tell jQuery not to set contentType
data: formData,
success: function(data) {
console.log(data);
}
});
-
I have no idea of posting multi part data from backbone view to rest web service.when looking for a solution..i am finding backbone with rails examples mostly.please suggest some examples. of using backbone with spring rest,Thank you @u.k – santosh karadla Nov 25 '15 at 18:16
-
I would use jQuery to do that. backbone doesn't have a specific implementation for file uploading – u.k Nov 25 '15 at 19:40
-
ok i will try by implementing it through jquery,Thank you @u.k – santosh karadla Nov 26 '15 at 04:04