Skip to content

CutieDaisy/angular-file

Repository files navigation

angular-file

Easy to use Angular directives for files upload (demo)

npm version npm downloads Build status Build Status Dependency Status

! UNDER CONSTRUCTION !

Forked from outdated package: ng2-file-upload This package works. Just needs more documentation, bells, and whistles

Table of Contents

Quick Start

  1. A recommended way to install angular-file is through npm package manager using the following command:

npm i angular-file --save-dev

Alternatively, you can download it in a ZIP file.

  1. Currently angular-file contains two directives: ngfSelect and ngFileDrop. ngfSelect is used for 'file-input' field of form and ngfDrop is used for area that will be used for dropping of file or files.

  2. More information regarding using of angular-file is located in demo and demo sources.

Examples

Select Files

Examples of how to allow file selection

Multiple

<input type="file" ngf [(files)]="files" multiple  />

Single

<input type="file" ngf [(file)]="file" />

Element

<div ngfSelect multiple="1" [(files)]="files">
  Tap to Select
</div>

Images Only

<button ngfSelect [(file)]="userFile" accept="image/*" multiple="1">
  Tap to Select
</button>
<div [ngfBackground]="userFile"
  style="background-size:cover;background-repeat:no-repeat;width:50px;height:50px"
></div>

Drop Files

Examples of how to allow file drag/drop

Basic

<div ngfDrop
  [(files)]="files"
  [(file)]="file"
  ([validDrag])="validDrag"
  ([invalidDrag])="invalidDrag"
  [ngClass]="{'myHoverClass': validDrag, 'myAntiHoverClass': validDrag}"
>
  Drop Files Here
</div>

Combo Drop Select

<div ngfDrop selectable="1" multiple="1"
  [(files)]="files"
  [(validDrag)]="validComboDrag"
  [(invalidDrag)]="invalidComboDrag"
  [ngClass]="{'goodDragClass':validComboDrag, 'badDragClass':invalidComboDrag}"
>
  Combo drop/select zone
</div>

API

ngf Directive

[multiple]:string
[accept]:string
[maxSize]:number
[forceFilename]:string
[forcePostname]:string
[ngfFixOrientation]:boolean = true
[fileDropDisabled] = false
[selectable] = false
[(ngf)]:ngf
[uploader]:FileUploader = new FileUploader({})
[(lastInvalids)]:{file:File,type:string}[] = []
[(fileUrl)]:string//last file uploaded url
[(file)]:File//last file uploaded
[(files)]:File[]

ngfDrop Directive

This directive extends ngf

(fileOver):EventEmitter<any> = new EventEmitter()
[(validDrag)] = false
[(invalidDrag)] = false

ngfSelect Directive

This directive extends ngf

[selectable] = true

ngfBackground Directive

[ngfBackground]:File

FileUploader

import { FileUploader } from "angular-file";

Properties

  • url - URL of File Uploader's route
  • authToken - Auth token that will be applied as 'Authorization' header during file send.
  • disableMultipart - If 'true', disable using a multipart form for file upload and instead stream the file. Some APIs (e.g. Amazon S3) may expect the file to be streamed rather than sent via a form. Defaults to false.
  • itemAlias - item alias (form name redefenition)

Troubleshooting

Please follow this guidelines when reporting bugs and feature requests:

  1. Use GitHub Issues board to report bugs and feature requests (not our email address)
  2. Please always write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our heads trying to reproduce it.

Thanks for understanding!

License

The MIT License (see the LICENSE file for the full text)

About

Angular components for user file select, drop, and more

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 91.2%
  • JavaScript 8.8%