ng2-uploader
For demos please see demos page.
Angular2 File Uploader
Installation
npm install ng2-uploader --save
Available parameters
Parameter | Example Value |
---|---|
url | http://api.ng2-uploader.com:10050 |
filterExtensions | true/false |
allowedExtensions | ['image/png', 'image/jpg'] or ['jpg', 'png'] |
calculateSpeed | true/false |
data | { userId: 12, isAdmin: true } |
customHeaders | { 'custom-header': 'value' } |
fieldName | 'user[avatar]' |
fieldReset | true/false |
authToken | 012313asdadklj123123 |
authTokenPrefix | 'Bearer' (default) |
All parameters except url
are optional.
Examples
Backend Examples
Basic Example
// app.module.ts;...// app.component.ts;
<!-- app.component.html --> <!-- drag & drop file example--> Response: {{ uploadFile | json }}
Advanced Example
This example show how to use available options and progress.
;
Backend Example Using HapiJS
'use strict'; const Hapi = ;const Inert = ;const Md5 = ;const Multiparty = ;const fs = ;const path = ;const server = ; server;server; const upload = payload: maxBytes: 209715200 output: 'stream' parse: false { const form = ; form; }; const uploads = handler: directory: path: path ; server; serverstart { console;};
Backend example using express
const express = ;const cors = ;const multer = ;const path = ; const app = ;app; const upload = ; app; app;
Backend example using plain PHP
Demos
For more information, examples and usage examples please see demos
LICENCE
MIT