Advertisement
julong

upload images

Nov 12th, 2015
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <input type="file" name="file" onchange="angular.element(this).scope().uploadFile(this)"/>
  2.  
  3. $scope.uploadFile = function(element) {
  4. var data = new FormData();
  5. data.append('file', $(element)[0].files[0]);
  6. jQuery.ajax({
  7. url: 'product/upload',
  8. type:'post',
  9. data: data,
  10. contentType: false,
  11. processData: false,
  12. success: function(response) {
  13. console.log(response); //callback
  14. },
  15. error: function(jqXHR, textStatus, errorMessage) {
  16. alert('Error uploading: ' + errorMessage);
  17. }
  18. });
  19. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement