Easy to use Angular directives for files upload (demo)
! UNDER CONSTRUCTION !
Forked from outdated package: ng2-file-upload This package works. Just needs more documentation, bells, and whistles
Table of Contents
- 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.
-
Currently
angular-file
contains two directives:ngfSelect
andngFileDrop
.ngfSelect
is used for 'file-input' field of form andngfDrop
is used for area that will be used for dropping of file or files. -
More information regarding using of angular-file is located in demo and demo sources.
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>
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>
[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[]
This directive extends ngf
(fileOver):EventEmitter<any> = new EventEmitter()
[(validDrag)] = false
[(invalidDrag)] = false
This directive extends ngf
[selectable] = true
[ngfBackground]:File
import { FileUploader } from "angular-file";
url
- URL of File Uploader's routeauthToken
- 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)
Please follow this guidelines when reporting bugs and feature requests:
- Use GitHub Issues board to report bugs and feature requests (not our email address)
- 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!
The MIT License (see the LICENSE file for the full text)