JavaScriptAngularJSMaterial Design Angular File Upload Component

Material Design Angular File Upload Component
M

This tool is a simple & configurable file upload component for use with Angular Material. you can use this component to upload files.

Prerequisites

In order to use mat-file-upload in your app, you must have the following dependencies installed:

  • Angular
  • Angular Material
  • Material Icons

Usage

  1. Install package from npm (npm i mat-file-upload).
  2. Add MatFileUploadModule to your module’s imports, like so:
@NgModule({
  declarations: [AppComponent],
  imports: [
    ...
    MatFileUploadModule,
    ...
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}
  1. Add the element to your template, like so:

Basic:

<mat-file-upload></mat-file-upload>

Advanced:

<mat-file-upload
  [labelText]="'Select a file (or multiple) to upload:'"
  [selectButtonText]="'Choose File(s)'"
  [selectFilesButtonType]="button"
  [uploadButtonText]="'Submit'"
  [uploadButtonType]="submit"
  [allowMultipleFiles]="true"
  [showUploadButton]="true"
  [customSvgIcon]="'close_custom'"
  [acceptedTypes]="'.png, .jpg, .jpeg'"
  (uploadClicked)="onUploadClicked($event)"
  (selectedFilesChanged)="onSelectedFilesChanged($event)"
>
</mat-file-upload>

Options

@Input() Properties

DirectiveTypeDescriptionDefault Value
[labelText]stringThe text to be displayed for the file upload label“Select file(s)”
[selectButtonText]stringThe text to be displayed for the button that allows the user to select file(s)“Select file(s)”
[selectFilesButtonType]stringThe HTML “type” attribute of the “Select Files” button“button”
[uploadButtonText]stringThe text to be displayed for the button that allows the user to upload file(s)“Upload File(s)”
[uploadButtonType]stringThe HTML “type” attribute of the “Upload” button“button”
[allowMultipleFiles]booleanTrue/false representing whether the user can select multiple files at a timefalse
[showUploadButton]booleanTrue/false representing whether the “Upload” button is shown in the DOMtrue
[customSvgIcon]stringThe name of the custom svgIcon to be used as the “close” button; otherwise defaults to Material’s “close” iconnull
[acceptedTypes]stringThe list of file types that are allowed to be uploaded“*.*”

@Output() Properties

DirectiveTypeDescription
(uploadClicked)EventEmitter<FileList>Event handler that emits the list of selected files whenever the “Upload” button is clicked
(selectedFilesChanged)EventEmitter<FileList>Event handler that emits the list of selected files whenever the user changes file selection

This awesome script developed by bjsawyer. Visit their official repository for more information and follow for future updates.

Saroj Meher
Saroj Meherhttps://www.sarojmeher.com
Howdy! Friends, I am Saroj Meher. I am an Artist. I do Painting on mediums like Acrylic, Watercolour, Oil etc. I have over 7 years of experience in WordPress. I am currently running 30+ website. I am specialized in WordPress and WooCommerce, WordPress Theme Customization and Theme Development. I can fix any kind of WordPress error/issue like PHP, CSS, Js issues and other Theme and Plugin related issues. Client's Satisfaction is my first priority.

Subscribe For More!

Subscribe to get the Latest Updates directly in you Email box.

Explore More

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

SAROJMEHER Photograph
I am a Lecturer (English & Sociology), a professional Artist, and a blogger. I do painting, sketches since my childhood. I am in the teaching for 10 years. In this teaching line, I have experience in teaching English at High School and College levels. I have also experienced teaching computer theory during the school teaching period. This is my personal web corner over the internet.

Quick Guides

7 Simple Steps To Start Your Blogging Journey

TRENDING TOPICS