FIleUpload plugin reset on form submit


Topic: FIleUpload plugin reset on form submit

mydancebay pro premium priority asked a year ago

Expected behavior FileUpload plugin resets uploaded files after form submit.

Actual behavior Files still uploaded in plugin.

Documentation for FIleUpload plugin API hasn't any methods to reset files. Is it possible somehow to do this?


r.seifert answered a year ago

We have public reset method that you can use to manually reset the plugin. Our docs API is missing this information and will be updated in the near future. Here is some code:

Template:

        <mdb-file-upload #fileUpload></mdb-file-upload>
        <button class="btn btn-danger" (click)="handleClick()">
          Reset file upload
        </button> 

Component class:

        import { Component, ViewChild } from '@angular/core';
        import { MdbFileUploadComponent } from 'mdb-angular-file-upload';

        @Component({
          selector: 'app-root',
          templateUrl: './app.component.html',
          styleUrls: ['./app.component.scss'],
        })
        export class AppComponent {
          @ViewChild('fileUpload') fileUpload!: MdbFileUploadComponent;

          handleClick(): void {
            this.fileUpload.reset();
          }
        }

mydancebay pro premium priority commented a year ago

Thank you for answer! Could you provide some code example please?


r.seifert commented a year ago

I've edited the original post and soon docs will be also updated.


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: MDB5 5.0.0
  • Device: Any
  • Browser: Any
  • OS: Any
  • Provided sample code: No
  • Provided link: No