Angular File Upload

后端 未结 12 2002
名媛妹妹
名媛妹妹 2020-11-22 10:04

I\'m a beginner with Angular, I want to know how to create Angular 5 File upload part, I\'m trying to find any tutorial or doc, but I don\'t see anything a

12条回答
  •  醉酒成梦
    2020-11-22 10:53

    Very easy and fastest method is using ng2-file-upload.

    Install ng2-file-upload via npm. npm i ng2-file-upload --save

    At first import module in your module.

    import { FileUploadModule } from 'ng2-file-upload';
    
    Add it to [imports] under @NgModule:
    imports: [ ... FileUploadModule, ... ]
    

    Markup:

    
    

    In your commponent ts:

    import { FileUploader } from 'ng2-file-upload';
    ...
    uploader: FileUploader = new FileUploader({ url: "api/your_upload", removeAfterUpload: false, autoUpload: true });
    

    It`is simplest usage of this. To know all power of this see demo

提交回复
热议问题