Gathering detailed insights and metrics for ng2-file-uploader
Gathering detailed insights and metrics for ng2-file-uploader
Gathering detailed insights and metrics for ng2-file-uploader
Gathering detailed insights and metrics for ng2-file-uploader
npm install ng2-file-uploader
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
3 Stars
18 Commits
2 Forks
2 Watchers
1 Branches
1 Contributors
Updated on Jun 04, 2025
Latest Version
0.1.4
Package Id
ng2-file-uploader@0.1.4
Size
9.48 kB
NPM Version
3.8.6
Node Version
5.0.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
npm install ng2-file-uploader
component.ts
1import {Component} from '@angular/core'; 2import {UPLOAD_DIRECTIVES} from 'ng2-file-uploader/ng2-file-uploader'; 3 4@Component({ 5 selector: 'demo-app', 6 templateUrl: 'app/demo.html', 7 directives: [UPLOAD_DIRECTIVES], 8}) 9export class DemoApp { 10 uploadFile: any; 11 postId: number; 12 options: Object = { 13 url: 'http://localhost:10050/upload', 14 params: { 'post_id': this.postId } 15 }; 16 17 handleUpload(data): void { 18 if (data && data.response) { 19 data = JSON.parse(data.response); 20 this.uploadFile = data; 21 } 22 } 23}
component.html
1<input type="file" 2 [ng-file-select]="options" 3 (onUpload)="handleUpload($event)"> 4 5<div> 6Response: {{ uploadFile | json }} 7</div>
component.ts
1import {Component} from '@angular/core'; 2import {UPLOAD_DIRECTIVES} from 'ng2-file-uploader/ng2-file-uploader'; 3 4@Component({ 5 selector: 'basic-multiple', 6 templateUrl: 'basic-multiple.html', 7 directives: [UPLOAD_DIRECTIVES], 8}) 9export class BasicMultiple { 10 uploadedFiles: any[] = []; 11 options: Object = { 12 url: 'http://localhost:80/upload' 13 }; 14 15 handleUpload(data): void { 16 if (data && data.response) { 17 data = JSON.parse(data.response); 18 this.uploadedFiles.push(data); 19 } 20 } 21}
component.html
1<input type="file" 2 style="display:none;" 3 [ng-file-select]="options" 4 (onUpload)="handleUpload($event)" 5 multiple> 6</div> 7 8<div> 9Response: <br/>{{ uploadedFiles | json }} 10</div>
component.ts
1import {Component, NgZone} from '@angular/core'; 2import {UPLOAD_DIRECTIVES} from 'ng2-file-uploader/ng2-file-uploader'; 3 4@Component({ 5 selector: 'basic-progressbar', 6 templateUrl: 'app/components/basic-progressbar/basic-progressbar.html', 7 directives: [UPLOAD_DIRECTIVES], 8}) 9export class BasicProgressbar { 10 uploadFile: any; 11 uploadProgress: number; 12 uploadResponse: Object; 13 zone: NgZone; 14 options: Object = { 15 url: 'http://localhost:80/upload' 16 }; 17 18 constructor() { 19 this.uploadProgress = 0; 20 this.uploadResponse = {}; 21 this.zone = new NgZone({ enableLongStackTrace: false }); 22 } 23 24 handleUpload(data): void { 25 this.uploadFile = data; 26 this.zone.run(() => { 27 this.uploadProgress = data.progress.percent; 28 }); 29 let resp = data.response; 30 if (resp) { 31 resp = JSON.parse(resp); 32 this.uploadResponse = resp; 33 } 34 } 35}
component.html
1<div> 2 <label for="file-pb" class="ui small black button right icon upload-button"> 3 <i class="ion-document icon"></i> 4 Choose file 5 </label> 6 <input type="file" 7 id="file-pb" 8 style="display:none;" 9 [ng-file-select]="options" 10 (onUpload)="handleUpload($event)"> 11</div> 12 13<div *ngIf="uploadFile"> 14Progress: {{ uploadProgress }}% 15</div> 16<div *ngIf="uploadFile"> 17 <div class="ui indicating olive progress"> 18 <div class="bar" [style.width]="uploadProgress + '%'"></div> 19 <div class="label">Uploading file ({{ uploadProgress }}%)</div> 20 </div> 21</div> 22 23<div> 24Response: <br/>{{ uploadFile | json }} 25</div>
component.ts
1import {Component, NgZone} from '@angular/core'; 2import {UPLOAD_DIRECTIVES} from 'ng2-file-uploader/ng2-file-uploader'; 3 4@Component({ 5 selector: 'multiple-progressbar', 6 templateUrl: 'app/components/multiple-progressbar/multiple-progressbar.html', 7 directives: [UPLOAD_DIRECTIVES] 8}) 9export class MultipleProgressbar { 10 uploadFiles: any[]; 11 uploadProgresses: any[] = []; 12 zone: NgZone; 13 options: Object = { 14 url: 'http://localhost:80/upload' 15 }; 16 17 constructor() { 18 this.zone = new NgZone({ enableLongStackTrace: false }); 19 } 20 21 handleUpload(data): void { 22 let id = data.id; 23 let index = this.findIndex(id); 24 if (index === -1) { 25 this.uploadProgresses.push({id: id, percent: 0}); 26 } 27 if (this.uploadProgresses[index]) { 28 this.zone.run(() => { 29 this.uploadProgresses[index].percent = data.progress.percent; 30 }); 31 } 32 } 33 34 findIndex(id: string): number { 35 return this.uploadProgresses.findIndex(x => x.id === id); 36 } 37 38}
component.html
1<div> 2 <label for="files-pb" class="ui small black button right icon upload-button"> 3 <i class="ion-document-text icon"></i> 4 Choose files 5 </label> 6 <input type="file" 7 id="files-pb" 8 style="display:none;" 9 [ng-file-select]="options" 10 (onUpload)="handleUpload($event)" 11 multiple> 12</div> 13 14<div class="ui divider"></div> 15 16<div *ngFor="#progressObj of uploadProgresses"> 17 <div class="ui indicating olive progress"> 18 <div class="bar" [style.width]="progressObj.percent + '%'"></div> 19 <div class="label">Uploading file ({{ progressObj.percent }}%)</div> 20 </div> 21</div>
component.ts
1import {Component} from '@angular/core'; 2import {UPLOAD_DIRECTIVES} from 'ng2-file-uploader/ng2-file-uploader'; 3 4@Component({ 5 selector: 'demo-app', 6 templateUrl: 'app/demo.html', 7 directives: [UPLOAD_DIRECTIVES], 8}) 9export class DemoApp { 10 uploadFile: any; 11 options: Object = { 12 url: 'http://localhost:80/upload', 13 withCredentials: true, 14 authToken: localStorage.getItem('token'), 15 authTokenPrefix: "Bearer" // required only if different than "Bearer" 16 17 }; 18 19 handleUpload(data): void { 20 if (data && data.response) { 21 data = JSON.parse(data.response); 22 this.uploadFile = data; 23 } 24 } 25}
component.html
1<input type="file" 2 [ng-file-select]="options" 3 (onUpload)="handleUpload($event)"> 4 5<div> 6Response: {{ uploadFile | json }} 7</div>
You may want to sent file with specific form field name. For that you can use options.fieldName. If not provided then the field will be named "file".
component.ts
1import {Component} from '@angular/core'; 2import {UPLOAD_DIRECTIVES} from 'ng2-file-uploader/ng2-file-uploader'; 3 4@Component({ 5 selector: 'demo-app', 6 templateUrl: 'app/demo.html', 7 directives: [UPLOAD_DIRECTIVES], 8}) 9export class DemoApp { 10 uploadFile: any; 11 options: Object = { 12 url: 'http://localhost:80/upload', 13 fieldName: 'logo' 14 }; 15 16 handleUpload(data): void { 17 if (data && data.response) { 18 data = JSON.parse(data.response); 19 this.uploadFile = data; 20 } 21 } 22}
component.html
1<input type="file" 2 [ng-file-select]="options" 3 (onUpload)="handleUpload($event)"> 4 5<div> 6Response: {{ uploadFile | json }} 7</div>
1<?php 2 3header("Access-Control-Allow-Origin: *"); 4 5if ($_SERVER['REQUEST_METHOD'] !== 'POST') { 6 echo json_encode(array('status' => false)); 7 exit; 8} 9 10$path = 'uploads/'; 11 12if (isset($_FILES['file'])) { 13 $originalName = $_FILES['file']['name']; 14 $ext = '.'.pathinfo($originalName, PATHINFO_EXTENSION); 15 $generatedName = md5($_FILES['file']['tmp_name']).$ext; 16 $filePath = $path.$generatedName; 17 18 if (!is_writable($path)) { 19 echo json_encode(array( 20 'status' => false, 21 'msg' => 'Destination directory not writable.' 22 )); 23 exit; 24 } 25 26 if (move_uploaded_file($_FILES['file']['tmp_name'], $filePath)) { 27 echo json_encode(array( 28 'status' => true, 29 'originalName' => $originalName, 30 'generatedName' => $generatedName 31 )); 32 } 33} 34else { 35 echo json_encode( 36 array('status' => false, 'msg' => 'No file uploaded.') 37 ); 38 exit; 39} 40 41?>
For more information, examples and usage examples please see demos
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
Reason
Found 0/18 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More