Search results

Trigger Click Event of Input File from External Button in Angular Uploader component

03 Oct 2022 / 1 minute to read

You can trigger the click event of input file from external button using click event of button. In the below sample, triggered click event of input file from Essential JavaScript 2 Button.

Copied to clipboard
import { Component, AfterViewInit } from '@angular/core';

    selector: 'app-root',
    templateUrl: 'default.html',
    styleUrls: ['index.css']

export class AppComponent {
    public autoUpload: boolean = false;
    public path: Object = {
        saveUrl: '',
        removeUrl: ''
    ngAfterViewInit(): void {
        document.getElementById('browse').onclick = (args) => {
Copied to clipboard
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { UploaderModule } from '@syncfusion/ej2-angular-inputs';

 * Module
    imports: [
        BrowserModule, UploaderModule
    declarations: [AppComponent],
    bootstrap: [AppComponent]
export class AppModule {
Copied to clipboard
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

Copied to clipboard
<div class="control-section">
    <div class="control_wrapper">
        <!-- Initialize Uploader -->
        <div id="dropArea">
            <span id="drop"> Drop image (JPG, PNG) files here or <button class='e-btn e-control' id="browse">Browse</button></span>
        <ejs-uploader #defaultupload id='fileupload' [asyncSettings]='path' [autoUpload]='autoUpload' ></ejs-uploader>

You can also explore Angular File Upload feature tour page for its groundbreaking features. You can also explore our Angular File Upload example to understand how to browse the files which you want to upload to the server.