Skip to content
Alex edited this page Jul 26, 2014 · 15 revisions

1. How do I deal with Cross Site Request Forgery protection?

See this issue: #40

For example, in Ruby on Rails, add an additional header, and use this method for verifying XSRF:

var csrf_token = document.querySelector('meta[name="csrf-token"]').getAttribute('content');

var uploader = $scope.uploader = new FileUploader({
    // your code here...
    headers : {
        'X-CSRF-TOKEN': csrf_token // X-CSRF-TOKEN is used for Ruby on Rails Tokens
    },
    //...
});

2. How to update FileItem options before uploading?

You can use uploader callback or item callback:

uploader.onBeforeUploadItem(function(item) {/* your code here */});
// or
item.onBeforeUpload(function() {/* your code here */});

3. I need custom options. Are there they?

Yes. See directives API.

4. "No file chosen" or "Re-add same file"

By default the value property of input element cleared after selection of files if the input have multiple attribute. If you do not clean this property then "change" event will not be fired if you select same file. You can manage this behavior:

  • Using multiple attribute
<!-- will be cleared -->
<input type="file" nv-file-select uploader="{FileUploader}" multiple/>
<!-- won't be cleared -->
<input type="file" nv-file-select uploader="{FileUploader}"/>
  • Override js function
FileUploader.FileSelect.prototype.isEmptyAfterSelection = function() {
    return {Boolean}; // true|false
};

See this function and change handler.

Clone this wiki locally