Topic: File input - reset value to null

Petr Urban priority asked 5 years ago


Hi there, is there any possibility how to programatically set the file input value to NULL? I'm using the following code for RESET button and it works fine:

resetForm(evt) {
                evt.preventDefault();
                /* Reset our form values */
                this.selectedBatchId = null;
                this.getBatchIds();
                this.selectedTestType = null;
                this.getTestTypes();
                this.testCaseFile = null;
                this.performanceFile = null;
                this.fullFilePath = null;
                this.fullPerformanceFilePath = null;
                sessionStorage.clear();
                /* Trick to reset/clear native browser form validation state */
                this.show = false;
                this.$nextTick(() => {
                    this.show = true
                });
            },

but I want the FILE INPUT value is reset automatically while changing the value for TestType (the file is related to TestType):

getTestCaseTypeValue(value) {
                this.selectedTestType = value;
                this.testCaseFile = null;
                this.fullFilePath = null;
                this.performanceFile = null;
                this.fullPerformanceFilePath = null;
            },

but the above construction doesn't allow the user to select some TestType -> Specify File -> Switch TestType (the file is NULL) -> Switch TestType back to one selected in first step -> Specify the same file as in the second step.


Magdalena Dembna staff answered 5 years ago


Hi, Unfortunately we don't provide an option to control file input's value from the outside. We are currently working on the solution and we hope it'll be available in the next release.

Kind regards,

Magdalena



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Vue
  • MDB Version: 5.1.1
  • Device: macBook
  • Browser: Safari
  • OS: Mac OS
  • Provided sample code: No
  • Provided link: No