danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.59k forks source link

How to distinguish text file or document selection text #1477

Open why520crazy opened 8 years ago

why520crazy commented 8 years ago

I drag document selection text or link,it will show drag-over-show class,if i add ngf-pattern to filter,the text file can't be work .

danialfarid commented 8 years ago

elaborate more, create a jsfiddle with steps to reproduce.

why520crazy commented 8 years ago

http://jsfiddle.net/s8kc7wg0/650/ select text “Upload Log” and drag it to drop area, it will show dragover style. image

danialfarid commented 8 years ago

Remove the ngf-drag-over-class or set the "reject" class to some non-existing class so it would not show the style on invalid drag.

danialfarid commented 8 years ago

When you drag over the content of what is being dragged is not completely available that's why it is not possible to detect the text or actual image being dragged. They will only be available after it has been dropped. So you can just have a specific pattern and make the reject class empty so it would not show it if you want only to allow dropping files from file system.

why520crazy commented 8 years ago

thanks.

http://jsfiddle.net/s8kc7wg0/654/

when set specific pattern ’.*‘, it's ok for drag the content, but drag file from file system can't be work, it should show over class , actually is reject class

danialfarid commented 8 years ago

Change it to ngf-pattern="*"

why520crazy commented 8 years ago

if set ngf-pattern="*", drag content “Upload Log” to drop area, it will show dragover style.

i expect that show dragover style only drag from system file.

givehug commented 5 years ago

this works for me ngf-drag-over-class="{accept:'dragover', pattern:'!text/*'}"