|
| 1 | +Angular file uploader is an Angular 2+ file uploader module with real-time progress bar and Angular Universal Compatibility. |
| 2 | + |
| 3 | +###Install |
| 4 | +``` |
| 5 | +npm install angular-file-uploader |
| 6 | +``` |
| 7 | +###Usage |
| 8 | +- Bootstrap.min.css is required. |
| 9 | + Include |
| 10 | + ```html |
| 11 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> |
| 12 | + ``` |
| 13 | + in your index.html. |
| 14 | +- Import FileUploadModule inside your app.module.ts |
| 15 | + ```javascript |
| 16 | + import { FileUploadModule } from "angular-file-uploader"; |
| 17 | + ``` |
| 18 | + ```javascript |
| 19 | + @NgModule({ |
| 20 | + imports: [ |
| 21 | + ..., |
| 22 | + FileUploadModule, |
| 23 | + ... |
| 24 | + ] |
| 25 | + }) |
| 26 | + ``` |
| 27 | +#####Example-1 |
| 28 | +```html |
| 29 | +<angular-file-uploader |
| 30 | + [uploadAPI]="'https://example-file-upload-api'"> |
| 31 | +</angular-file-uploader> |
| 32 | +``` |
| 33 | +#####Example-2 |
| 34 | +```html |
| 35 | +<angular-file-uploader |
| 36 | + [multiple]="true" |
| 37 | + [formatsAllowed]="'.jpg,.png'" |
| 38 | + [maxSize]="5" |
| 39 | + [uploadAPI]="'https://example-file-upload-api'" |
| 40 | + [resetUpload]=resetUpload |
| 41 | + (ApiResponse)="DocUpload($event)"> |
| 42 | +</angular-file-uploader> |
| 43 | +``` |
| 44 | + |
| 45 | +| **Properties** | **Description** | **Default Value** | |
| 46 | +|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------| |
| 47 | +| multiple : boolean | true- multiple file upload. false- single file upload | false | |
| 48 | +| formatsAllowed : string | specify the formats of file you want to upload. | '.jpg,.png,.pdf,.docx, .txt,.gif,.jpeg' | |
| 49 | +| uploadAPI : string | complete api url to which you want to upload. | undefined | |
| 50 | +| maxSize : number | maximum size limit for files in MB. | 20 | |
| 51 | +| ApiResponse : EventEmitter | assign one custom function ,for example " DocUpload($event) " here where " $event " will contain the response from the api. | | |
| 52 | +| resetUpload : boolean | give it's value as " true " whenever you want to clear the list of uploads being displayed. It's better to assign one boolean variable (resetUpload here)to it and then change that variable's value. | false | |
| 53 | + |
| 54 | +#####Points to note: |
| 55 | +- Set resetUpload as true to reset the module instantly. |
| 56 | + Remember to change resetUpload value 'true' to 'false' after every reset. |
| 57 | +- ApiResponse will return the response it gets back from the uploadAPI. |
| 58 | +- Files are uploaded in FormData format. |
| 59 | + |
| 60 | +###Coming Soon: |
| 61 | +- Multiple themes. |
| 62 | +- Drag n Drop. |
| 63 | +- More customization options. |
0 commit comments