Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • AngularJS Tutorial
  • AngularJS Directives
  • AngularJS Functions
  • AngularJS Filters
  • AngularJS Examples
  • AngularJS Interview Questions
  • Angular ngx Bootstrap
  • AngularJS Cheat Sheet
  • AngularJS PrimeNG
  • JavaScript
  • Web Technology
Open In App
Next Article:
Angular PrimeNG FileUpload Multiple Uploads
Next article icon

Angular PrimeNG FileUpload Advanced

Last Updated : 26 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to use FileUpload Advanced in Angular PrimeNG.

Angular PrimeNG FileUpload Advanced Mode mode provides a simpler UI as an alternative to basic mode.

Angular PrimeNG FileUpload Advanced Properties:

  • multiple: It is used to select multiple files at once. It is of boolean data type, the default value is false.
  • accept: It is the pattern to restrict the allowed file types. It is of string data type, the default value is false.

Creating Angular application & Module Installation:

Step 1: Create an Angular application using the following command.

ng new appname

Step 2: After creating your project folder i.e. appname, move to it using the following command.

cd appname

Step 3: Install PrimeNG in your given directory.

npm install primeng --save  npm install primeicons --save

Project Structure: It will look like the following:

 

Steps to run the application: Run the below command to see the output

npm start

Example 1: Below is an example code that illustrates the use of Angular PrimeNG FileUpload Advanced Component using single file upload.

app.component.html:

HTML

<h1 style="color: green">GeeksforGeeks</h1>
<h4> Angular PrimeNG FileUpload Advanced Component.</h4>
  
<p-fileUpload name="demo[]" 
    url="./upload.php" 
    (onUpload)="onUpload($event)"
    accept="image/*" 
    maxFileSize="1000000">
    <ng-template pTemplate="content">
        <ul *ngIf="uploadedFiles.length">
            <li *ngFor="let gfg of uploadedFiles">
              {{gfg.name}} - {{gfg.size}} bytes
          </li>
        </ul>
    </ng-template>
</p-fileUpload>
                      
                       

app.component.ts:

Javascript

import { Component } from '@angular/core';
import { MessageService } from 'primeng/api';
import { PrimeNGConfig } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    providers: [MessageService],
})
  
export class AppComponent {
    uploadedGFG: any[] = [];
  
    constructor(private messageService: MessageService, 
        private primengConfig: PrimeNGConfig
    ){}
  
    onUpload(event) {
        for (let file of event.files) {
          this.uploadedGFG.push(file);
        }
  
        this.messageService.add({
            severity: 'info',
            summary: 'File Uploaded',
            detail: 'File uploaded successfully',
        });
    }
}
                      
                       

app.module.ts:

Javascript

import { NgModule } from '@angular/core';
import { BrowserModule }
    from '@angular/platform-browser';
import { BrowserAnimationsModule }
    from '@angular/platform-browser/animations';
import { FileUploadModule } from 'primeng/fileupload';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { ButtonModule } from 'primeng/button';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        ButtonModule,
        HttpClientModule,
        FileUploadModule,
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
  
export class AppModule { }
                      
                       

Output:

 

Example 2: Below is another example code that illustrates the use of Angular PrimeNG FileUpload Advanced Component using multiple file upload.

app.component.html:

HTML

<h1 style="color: green">GeeksforGeeks</h1>
<h4> Angular PrimeNG FileUpload Advanced Component.</h4>
  
<p-fileUpload name="demo[]" 
    url="./upload.php" 
    (onUpload)="onUpload($event)"
    multiple="multiple" accept=".txt" 
    maxFileSize="1000000">
    <ng-template pTemplate="content">
        <ul *ngIf="uploadedGFG.length">
            <li *ngFor="let gfg of uploadedFiles">
              {{gfg.name}} - {{gfg.size}} bytes
          </li>
        </ul>
    </ng-template>
</p-fileUpload>
                      
                       
  • app.component.ts:

Javascript

import { Component } from '@angular/core';
import { MessageService } from 'primeng/api';
import { PrimeNGConfig } from 'primeng/api';
  
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    providers: [MessageService],
})
  
export class AppComponent {
    uploadedGFG: any[] = [];
  
    constructor(private messageService: MessageService, 
        private primengConfig: PrimeNGConfig
    ){}
  
    onUpload(event) {
        for (let file of event.files) {
          this.uploadedGFG.push(file);
        }
  
        this.messageService.add({
          severity: 'info',
          summary: 'File Uploaded',
          detail: 'File uploaded successfully',
        });
    }
}
                      
                       

app.module.ts:

Javascript

import { NgModule } from '@angular/core';
import { BrowserModule }
    from '@angular/platform-browser';
import { BrowserAnimationsModule }
    from '@angular/platform-browser/animations';
import { FileUploadModule } from 'primeng/fileupload';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { ButtonModule } from 'primeng/button';
  
@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        ButtonModule,
        HttpClientModule,
        FileUploadModule,
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent],
})
  
export class AppModule { }
                      
                       

Output:

 

Reference: https://primefaces.org/primeng/fileupload



Next Article
Angular PrimeNG FileUpload Multiple Uploads

C

cool007
Improve
Article Tags :
  • AngularJS
  • Technical Scripter
  • Web Technologies
  • Angular-PrimeNG
  • Technical Scripter 2022

Similar Reads

  • Angular PrimeNG FileUpload Basic
    Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to use FileUpload Basic in Angular PrimeNG. Angular PrimeNG FileUpl
    3 min read
  • Angular PrimeNG FileUpload Advanced
    Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to use FileUpload Advanced in Angular PrimeNG. Angular PrimeNG File
    3 min read
  • Angular PrimeNG FileUpload Multiple Uploads
    Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to use the FileUpload Multiple Uploads in Angular PrimeNG. Angular
    2 min read
  • Angular PrimeNG FileUpload DragDrop
    Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to use the FileUpload DragDrop in Angular PrimeNG. Angular PrimeNG
    3 min read
  • Angular PrimeNG FileUpload Auto Uploads
    Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to use the FileUpload Auto Uploads in Angular PrimeNG. Angular Prim
    3 min read
  • Angular PrimeNG FileUpload File Types
    Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use FileUpload File Types in Angular PrimeNG. The FileUpload Compon
    3 min read
  • Angular PrimeNG FileUpload File Size
    Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use FileUpload File Size in Angular PrimeNG. The FileUpload Compone
    3 min read
  • Angular PrimeNG FileUpload Templating
    Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will know how to use FileUpload Templating in Angular PrimeNG. The FileUpload Co
    3 min read
  • Angular PrimeNG FileUpload Basic UI
    Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. This article will show us how to use FileUpload Basic UI in Angular PrimeNG. Angular PrimeNG FileUpl
    3 min read
  • Angular PrimeNG FileUpload Custom Upload
    Angular PrimeNG is an open-source framework with a rich set of native Angular UI components that are used for great styling and this framework is used to make responsive websites with very much ease. In this article, we will see how to use the FileUpload Custom Upload in Angular PrimeNG. Angular Pri
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences