flowjs / ng-flow

Flow.js html5 file upload extension on angular.js framework
http://flowjs.github.io/ng-flow/
MIT License
1.38k stars 303 forks source link

how to limit the type of upload file #306

Open hank-hong opened 8 years ago

hank-hong commented 8 years ago

The version I used is: angular ~1.2.0 ng-flow ~2

HTML :

<div flow-init="{singleFile:true}" 
        flow-file-added="handlerImageAdded($file, $event, $flow)" >
      .......
           <span class="btn btn-info" flow-btn flow-attrs="{accept:'image/*'}" >Upload Image</span>
</div>

<div flow-init="{singleFile:true}" 
        flow-file-added="handlerCsvAdded($file, $event, $flow)" >
      .......
           <span class="btn btn-info" flow-btn flow-attrs="{accept:'text/csv'}" >Upload CSV</span>
</div>

I want to upload file only in image (.jpg, .png, *.bmp) and csv format.

Accoridng to some suggestion, I used attribute flow-attrs="{accept:'.....'}" in HTML, but I found they seem not work. I have to check the file suffix in js method.

Could you please tell me if we could have a better way?

Thanks

shailesh87 commented 8 years ago

Hi, using "flow-file-added " event handler you can limit the type of uploaded file. In my project i am using like this...

flow-file-added="!!{png:1,gif:1,jpg:1,jpeg:1,csv:1}"

hank-hong commented 8 years ago

Hello @shailesh87

Thanks very much, it works.