leewinder / ng2-file-drop

An Angular module for simple desktop file drag and drop with automatic file validation and dynamic style adjustment.
MIT License
28 stars 26 forks source link

Change supportedFileTypes to accept non-picture filetypes #22

Closed justmatt25 closed 7 years ago

justmatt25 commented 7 years ago

Basically I need to be able to accept .pdf, .xlsx, etc but I can't seem to figure out how to do it. I tried editing this line of code: private supportedFileTypes: string[] = ['image/png', 'image/jpeg', 'image/gif', ]; but it didn't seem to take. How would I go about doing this?

leewinder commented 7 years ago

Check out the following

In 'image-validation', the array type passed enabled the files the drop zone accepts (you just need to identify what the file type is for pdf, xlsx etc.).

In 'size-validation' the type array is omitted showing how you can accept any file type.

Jagdeep1 commented 7 years ago

For Excel Files 97-2003 (.xls), use: application/vnd.ms-excel For Excel Files 2007+ (.xlsx), use: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet For CSV files (.csv), use: .csv

In my application I am supporting above 3, so supported file array looks like supportedFileTypes: string[] = ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', '.csv'];

For more details refer to this link https://stackoverflow.com/questions/11832930/html-input-file-accept-attribute-file-type-csv