-3

Like in the title, how I can check if the file input is empty? And bind the result to $scope.

Duc Minh Vu
  • 11
  • 1
  • 3

1 Answers1

-4

Natively you can't, because file uploading are more complex than that.

In order to trigger and upload of a file you have to use a multipart request which is different from a simple AJAX JSON request.

Of course since angularJS is a very popular framework you have a plugin for this : https://github.com/danialfarid/ng-file-upload. You will find every thing you need :

  1. How to upload a file
  2. How to restrict a file (content type, weight, ...).
  3. It even show some use case about how handling that on server side for Spring/Rails/NodeJS/PHP,...
Walfrat
  • 5,363
  • 1
  • 16
  • 35