Ng2 File Upload screenshot

Ng2 File Upload

Author Avatar Theme by Valor software
Updated: 15 Jan 2025
1912 Stars

Easy to use Angular components for files upload

Categories

Overview:

The ng2-file-upload is an Angular 2 library that provides easy-to-use directives for file uploads. It includes directives such as ng2-file-select for file input fields and ng2-file-drop for areas where files can be dropped. The library simplifies the process of handling file uploads in Angular 2 projects.

Features:

  • Easy to use directives: Includes directives like ng2-file-select and ng2-file-drop for handling file uploads.
  • Installation through npm: Can be easily installed using npm package manager.
  • API for file selection and drop: Provides properties like uploader object, URL, authToken, and event triggers for file selection and drop.

Installation:

To install ng2-file-upload, follow these steps:

  1. Install using npm:
npm i ng2-file-upload
  1. Import FileUploadModule into the module:
import { FileUploadModule } from 'ng2-file-upload';
  1. Add FileUploadModule to the imports section in @NgModule:
imports: [ ... FileUploadModule, ... ]
  1. Import FileUploader into the component:
import { FileUploader } from 'ng2-file-upload';
  1. Define an API URL:
const URL = 'path_to_api';
  1. Initialize the uploader object:
public uploader: FileUploader = new FileUploader({ url: URL });

Summary:

The ng2-file-upload library provides Angular 2 developers with a convenient way to handle file uploads by offering directives and APIs for file selection and drop. The installation process is straightforward via npm, making it easy to integrate into Angular 2 projects. Overall, ng2-file-upload simplifies the task of managing file uploads in Angular 2 applications.