Gathering detailed insights and metrics for angular-file
Gathering detailed insights and metrics for angular-file
Gathering detailed insights and metrics for angular-file
Gathering detailed insights and metrics for angular-file
angular-file-upload
Angular File Upload is a module for the AngularJS framework
ng2-file-upload
Angular file uploader
@syncfusion/ej2-angular-filemanager
Essential JS 2 FileManager Component for Angular
angular-file-saver
An AngularJS service that implements the HTML5 W3C saveAs() in browsers that do not natively support it
npm install angular-file
Typescript
Module System
Node Version
NPM Version
93.4
Supply Chain
100
Quality
76.2
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
128 Stars
211 Commits
40 Forks
8 Watchers
3 Branches
3 Contributors
Updated on Apr 19, 2025
Latest Version
4.0.2
Package Id
angular-file@4.0.2
Unpacked Size
736.34 kB
Size
175.50 kB
File Count
48
NPM Version
8.5.0
Node Version
16.14.2
Published on
May 16, 2023
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
1
Easy to use Angular directives for user file selections (DEMO PAGE)
This package is to handle select/drag/drop of files. Once files are selected, for uploading, you then use Angular's
@angular/common/http
for uploading selected files (see here for more on uploading).
npm install angular-file --save-dev
Alternatively, you can download it in a ZIP file.
Currently angular-file
contains three directives: ngf
, ngfSelect
, and ngfDrop
. ngf
and ngfSelect
are quite the same with just different defaults and they both utilize <input type="file" />
functionality. ngfDrop
is used to designate an area that will be used for dropping of file(s).
More information regarding using of angular-file is located in demo and demo sources.
An example intended to have every line needed to run an app with angular-file. To use this example, replace the contents of main.ts with this code, and add <app></app>
to the body of index.html
1import { ngfModule, ngf } from "angular-file" 2import { Component, NgModule } from "@angular/core" 3import { 4 HttpClient, HttpClientModule, HttpRequest, HttpResponse, HttpEvent 5} from "@angular/common/http" 6import { platformBrowserDynamic } from "@angular/platform-browser-dynamic" 7import { BrowserModule } from '@angular/platform-browser' 8import { Subscription } from 'rxjs' 9 10// two ways to upload files 11const template = ` 12<input 13 ngf 14 multiple 15 type = "file" 16 accept = "image/*" 17 [(files)] = "files" 18 maxSize = "1024" 19 capturePaste = "1" 20/> 21<button *ngIf="files" (click)="uploadFiles(files)">send files</button> 22 23<ngfFormData 24 [files] = "files" 25 [(FormData)] = "myFormData" 26 postName = "file" 27></ngfFormData> 28 29<ngfUploadStatus 30 [(percent)] = "uploadPercent" 31 [httpEvent] = "httpEvent" 32></ngfUploadStatus> 33 34<div *ngIf="uploadPercent"> 35 Upload Progress: {{ uploadPercent }}% 36</div> 37` 38 39@Component({ 40 selector: 'app', 41 template: template 42}) 43export class AppComponent { 44 postUrl = '...' 45 myFormData:FormData//populated by ngfFormData directive 46 httpEvent:HttpEvent<{}> 47 48 constructor(public HttpClient:HttpClient){} 49 50 uploadFiles(files:File[]) : Subscription { 51 const config = new HttpRequest('POST', this.postUrl, this.myFormData, { 52 reportProgress: true 53 }) 54 55 return this.HttpClient.request( config ) 56 .subscribe(event=>{ 57 this.httpEvent = event 58 59 if (event instanceof HttpResponse) { 60 alert('upload complete, old school alert used') 61 } 62 }, 63 error=>{ 64 alert('!failure beyond compare cause:' + error.toString()) 65 }) 66 } 67} 68 69@NgModule({ 70 imports: [ 71 BrowserModule, 72 HttpClientModule, 73 ngfModule 74 ], 75 declarations: [ 76 AppComponent 77 ], 78 bootstrap: [AppComponent] 79}) 80export class AppModule {} 81 82platformBrowserDynamic().bootstrapModule(AppModule);
Examples of how to allow file selection
Multiple
1<input type="file" ngf [(files)]="files" multiple />
Single
1<input type="file" ngf [(file)]="file" />
Element
1<div ngfSelect multiple="1" [(files)]="files"> 2 Tap to Select 3</div>
Image Backgrounds Only
1<button ngfSelect [(file)]="userFile" accept="image/*" multiple="1"> 2 Tap to Select 3</button> 4<div [ngfBackground]="userFile" 5 style="background-size:cover;background-repeat:no-repeat;width:50px;height:50px" 6></div>
Images Only
1<button ngfSelect [(file)]="userFile" accept="image/*" multiple="1"> 2 Tap to Select 3</button> 4<img [ngfSrc]="userFile" />
Examples of how to allow file drag/drop
Basic
1<div ngfDrop 2 [(files)]="files" 3 [(file)]="file" 4 ([validDrag])="validDrag" 5 ([invalidDrag])="invalidDrag" 6 [ngClass]="{'myHoverClass': validDrag, 'myAntiHoverClass': validDrag}" 7> 8 Drop Files Here 9</div>
Combo Drop Select
1<div ngfDrop selectable="1" multiple="1" 2 [(files)]="files" 3 [(validDrag)]="validComboDrag" 4 [(invalidDrag)]="invalidComboDrag" 5 [ngClass]="{'goodDragClass':validComboDrag, 'badDragClass':invalidComboDrag}" 6> 7 Combo drop/select zone 8</div>
A base directive that provides abilities of ngfDrop and ngfSelect. Does not auto default nor auto host element events like hover/drag/drop (see ngfDrop and/or ngfSelect)
1ngf : ngf // reference to directive class 2[multiple] : string 3[accept] : string 4[maxSize] : number // bytes . 1024 = 1k . 1048576 = 1mb 5[ngfFixOrientation] : boolean = true 6[fileDropDisabled] : any = false 7[selectable] : any = false 8[(lastInvalids)] : {file:File,type:string}[] = [] 9[(lastBaseUrl)] : string // Base64 od last file uploaded url 10[(file)] : File // last file uploaded 11[(files)] : File[] 12(init) : EventEmitter<ngf> 13[capturePaste] : boolean // listen to window paste event for files 14(fileSelectStart) : EventEmitter<Event> // Event fired for user selecting files starting
Extends ngf and then auto hosts element event watching of hover/drag/drop
1[fileDropDisabled] : any = false 2(fileOver) :EventEmitter<any> = new EventEmitter() 3[(validDrag)] :any = false 4[(invalidDrag)] :any = false
Supporting Internet Explorer 11 or less?
Only (fileOver) works accurately [(validDrag)] & [(invalidDrag)] should NOT be used as IE11 does not indicate the number of files NOR the types of files being dragged like other modern web browsers
Extends ngf and auto engages click base file selecting
1[selectable]:any = true
1[ngfBackground]:File
1[ngfSrc]:File
Does calculations of an upload event and provideds percent of upload completed
1[(percent)]:number 2[httpEvent]:Event
Converts files to FormData
1[files]:File[] 2[postName]:string = "file" 3[fileName]:string//optional force file name 4[(FormData)]:FormData
Angular, natively, makes uploading files so very easy!
Did you know?
@angular/common
@angular/common
to send files! Why add more unneccessary weight of dependency of another package?@angular/common
Uploading files is as easy as:
import { Subscription } from "rxjs"//only included for data typing
import {
HttpClient, HttpRequest, HttpResponse
} from "@angular/common/http"
export const uploadFiles(files:File[]) : Subscription {
const postUrl = "..."
const myFormData:FormData = new FormData()
files.forEach(file=>myFormData.append("file", file, "file-name.xyz"))
const config = new HttpRequest("POST", postUrl, myFormData), {
reportProgress: true
})
return this.HttpClient.request( config )
.subscribe(event=>{
if (event instanceof HttpResponse) {
alert('upload complete, old school alert used')
}
},
error=>{
alert('!failure cause:' + error.toString())
})
}
Please follow this guidelines when reporting bugs and feature requests:
Thanks for understanding!
Work on this package
Source files are on not the default github branch
git clone https://github.com/AckerApple/angular-file.git -b development
The MIT License (see the LICENSE file for the full text)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/29 approved changesets -- 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
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
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