2

I am using ng-flow in my app, is there any way to limit the number of files for upload?

A code sample:

<div class="thumbnail" ng-show="$flow.files.length">
  <img flow-img="$flow.files[0]" />
</div>
<div>
  <a href="#" class="btn" ng-hide="$flow.files.length" flow-btn flow-attrs="{accept:'image/*'}">Select image</a>
  <a href="#" class="btn" ng-show="$flow.files.length" flow-btn flow-attrs="{accept:'image/*'}">Change</a>
  <a href="#" class="btn btn-danger" ng-show="$flow.files.length"
     ng-click="$flow.cancel()">
    Remove
  </a>
</div>
anapap
  • 21
  • 6

1 Answers1

0

The attribute flow-file-added is expecting a boolean value. You can put all your conditions in there. $flow.files.length returns the number a files you have already added

For example:

<div flow-init flow-files-submitted="$flow.upload()" flow-file-added="$flow.files.length<3"></div>
Community
  • 1
  • 1
Aminovski
  • 145
  • 1
  • 5
  • Good answers *explain* as well as provide code. Consider updating your answer to include an explanation about how this code works and why it is the best option. – Ajean Sep 04 '15 at 00:05
  • flow-file-added is expecting a boolean value. You can put all your conditions in there. $flow.files.length returns the number a files you have already added. – Aminovski Sep 04 '15 at 16:29
  • Don't just comment. Edit your answer! – Ajean Sep 04 '15 at 19:08
  • Is there a way to do this for Drag&Drop as well? flow-file-added doesn't work in this case – bnunamak Jul 16 '16 at 07:52