[FIXED] Angular: Open file dialog upon button click


I’m using Angular 8.
Upon button click I want to open a file dialog, select a file and then call an event that will handle this file.

Thank you,

I tried the following code in HTML.
But I do not want anything to be displayed in HTML.


<p-fileUpload name="myfile[]" customUpload="true" auto="true" (uploadHandler)="onOpenFile($event)" accept="application/pdf"></p-fileUpload>


public onOpenFile (event)


You can achieve this with normal input tag , you can make it hidden, but at least you need one element to trigger the click event. Check stackblitz

Answered By – Abhinav Kumar

Answer Checked By – Gilberto Lyons (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published