Topic: FIleUpload plugin reset on form submit

mydancebay priority asked 8 months 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?


Rafał Seifert staff answered 8 months 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 priority commented 8 months ago

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


Rafał Seifert staff commented 8 months 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

  • ForumUser: Priority
  • 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