ngUpload

An AngularJS Service for uploading files using iframe
27 people use it
Author: 21292?v=2 twilson63

ngUpload

An AngularJS file upload directive.

0.5.1 - for updates see CHANGELOG.md

... and the context ngController's source is:

Requirements

Install with Bower

Usage

Add to your html file

Create a basic form with a file input element

Some rule of thumb

  • Any html element that supports the click event can be used to submit the form marked with the ng-upload directive, as long as such elements are marked with the 'upload-submit' directive. If you use an input element with a type of submit then you do not have to mark it with upload-submit.
  • Make sure you import the 'ngUpload' module in your angularJS application.

Applying this rules, the sample above can be re-written as

or

where the form can be submit with a Div or Anchor html element.

The AngularJS controller for the above samples is given as:

  • Working in IE

In order, for ngUpload to respond correctly for IE, your server needs to return the response back as html/text not application/json

Directive Options

ngUpload

  • upload-options-enable-rails-csrf: Turns on support for Rails' CSRF by adding a hidden form field with the csrf token.

  • ng-upload-loading: function that gets triggered when the upload starts.

  • ng-upload-before-submit: function that gets triggered before the upload starts and if the function returns false it will cancel the submit.

uploadSubmit

  • upload-options-convert-hidden: Set the value of hidden inputs to their ng-model attribute when the form is submitted.

Example

Example of forms that posts to NodeJS server are now included under the /examples folder.

Test

Needs Chrome Installed.

jshint

Minify

License

MIT

How to contribute

pull requests welcome.

please use the following style guidelines

(http://nodeguide.com/style.html)

Contributors

Thanks

  • AngularJS Team
  • NodeJS Team
  • JavaScript Team
comments powered by Disqus
This page was last updated about 1 year ago.