Skip to content

A Html input file enhance base on angular material to file input or file upload.

License

Notifications You must be signed in to change notification settings

c4e/angular-material-fileinput

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Angular Material File Input

A Html file input enhance base on angular material.

This directive try to make input file or file upload intuitive.

screensho 0

screensho 1

Demo

Live Demo

Getting Started

Install with Bower or download the files directly from the dist folder in the repo.

bower install lf-ng-md-file-input --save

Add dist/lf-ng-md-file-input.js and dist/lf-ng-md-file-input.css to your index.html.

<!-- Angular Material Dependencies -->
<link rel="stylesheet" href="./bower_components/angular-material/angular-material.min.css">
<script src="./bower_components/angular/angular.min.js"></script>
<script src="./bower_components/angular-animate/angular-animate.min.js"></script>
<script src="./bower_components/angular-aria/angular-aria.min.js"></script>
<script src="./bower_components/angular-material/angular-material.min.js"></script>

<!-- Angular Material Fileinput -->
<link rel="stylesheet" href="./bower_components/lf-ng-md-file-input/dist/lf-ng-md-file-input.css">
<script src="./bower_components/lf-ng-md-file-input/dist/lf-ng-md-file-input.js"></script>

Add lfNgMdFileInput as a module dependency for your module.

var app = angular.module('app', ['ngMaterial','lfNgMdFileInput']);

##Usage

This angular directive is focus on make material look and upload file base on ajax.

So the most important thing is you need fetch files yourself from "lf-files" data bind, not input element because it will clear every time after resolve file.

The "lf-files" data is an array variable, object in array contain properties with lfFileName(file name) 、 lfFile(file object) and lfDataUrl(for preview) from resolve input file.

You can observe "lf-files" by using $watch.

####html

    <lf-ng-md-file-input lf-files='files' multiple> </lf-ng-md-file-input>

####javascript

    app.controller('MyCtrl',function($scope){
        $scope.$watch('files.length',function(newVal,oldVal){
            console.log($scope.files);
        });
    });

So after you finish select files you need adjust data like below to fit your server side.

####client

    app.controller('MyCtrl',function($scope){

        ...

        $scope.onSubmit = function(){
            var formData = new FormData();
            angular.forEach($scope.files,function(obj){
                if(!obj.isRemote){
                    formData.append('files[]', obj.lfFile);
                }
            });
            $http.post('./upload', formData, {
                transformRequest: angular.identity,
                headers: {'Content-Type': undefined}
            }).then(function(result){
                // do sometingh                   
            },function(err){
                // do sometingh
            });
        };

        ...

    });

In this example I use node.js( express + formidable ) & ( express + multer ) on server side, "Formidable & Multer" is a node module for parsing form data.

####server #####Formidable

    var express = require('express');
    var formidable = require('formidable');
    var app = express();
    app.use(express.static(__dirname + '/public'));

    ...

    app.post('/upload',function(req,res){
        var form = new formidable.IncomingForm();
        form.uploadDir = __dirname +'/public/uploads';
        //file upload path
        form.parse(req, function(err, fields, files) {
            //you can get fields here
        });
        form.on ('fileBegin', function(name, file){
            file.path = form.uploadDir + "/" + file.name;
            //modify file path
        });
        form.on ('end', function(){
            res.sendStatus(200);
            //when finish all process    
        });
    });

    ...

#####Muliter

    var express = require('express');
    var multer = require('multer');
    var app = express();
    app.use(express.static(__dirname + '/public'));

    ...

    var storage = multer.diskStorage({
        destination: function (req, file, cb) {
            cb(null, __dirname +'/public/uploads');
            //modify upload dest
        },
        filename: function (req, file, cb) {
            cb(null, file.originalname);
            //modify file name
        }
    });
    var upload = multer({ "storage": storage });
    var type = upload.array('files[]');

    app.post('/upload',type,function(req,res){
        res.sendStatus(200);
    });

    ...

###Basic

<lf-ng-md-file-input lf-files="files"></lf-ng-md-file-input>

###Aria-label

<lf-ng-md-file-input lf-files="files" aria-label="fileupload"></lf-ng-md-file-input>

###Accept

Accept attribute only support MIME type (e.g: image/* , image/jpeg , video/* , video/mp4)

<lf-ng-md-file-input lf-files="files" accept="image/*"></lf-ng-md-file-input>

###Multiple

<lf-ng-md-file-input lf-files="files" multiple></lf-ng-md-file-input>

###Progress

<lf-ng-md-file-input lf-files="files" progress></lf-ng-md-file-input>

###Placeholder

<lf-ng-md-file-input lf-files="files" lf-placeholder="my placeholder"></lf-ng-md-file-input>

###Caption

<lf-ng-md-file-input lf-files="files" lf-caption="my caption"></lf-ng-md-file-input>

###Preview

<lf-ng-md-file-input lf-files="files" preview></lf-ng-md-file-input>

###Drag

<lf-ng-md-file-input lf-files="files" drag></lf-ng-md-file-input>

###Change labels

<lf-ng-md-file-input lf-files="files" lf-drag-and-drop-label="Drag and Drop this" drag></lf-ng-md-file-input>
<lf-ng-md-file-input lf-files="files" lf-browse-label="Browse..."></lf-ng-md-file-input>
<lf-ng-md-file-input lf-files="files" lf-remove-label="Trash"></lf-ng-md-file-input>

###Reset internal lfFiles

<lf-ng-md-file-input lf-files="files" drag lf-api="lfApi"></lf-ng-md-file-input>

Corresponding javascript controller

    /**
     * Upload using your own API
     */
    upload().then(function(response)
    {
        /**
         * Do stuff
         * ...
         */
         /**
          * Reset the contents of file input
          */
         $scope.lfApi.removeAll();
    });

###Validation

Attribute Description
lf-required file input required
lf-maxcount files count limit
lf-filesize per file size limit
lf-totalsize total files size limit
lf-mimetype mime type check

lf-filesize and lf-totalsize must require number with unit . (e.g: 5Byte, 100KB, 5MB)

<form name="testForm" layout="column">
    <lf-ng-md-file-input name="files" lf-files="files" lf-required lf-maxcount="5" lf-filesize="10MB" lf-totalsize="20MB" lf-mimetype="image/*" multiple drag preview></lf-ng-md-file-input>
    <div ng-messages="testForm.files.$error" style="color:red;">
        <div ng-message="required">This is required.</div>
        <div ng-message="maxcount">Too many files.</div>
        <div ng-message="filesize">File size too large.</div>
        <div ng-message="totalsize">Total size too large.</div>
        <div ng-message="mimetype">Mimetype error.</div>
    </div>
</form>

###API

Name Parameter Description
removeByName name(string) Remove file by name
removeAll Remove all file
addRemoteFile url(string), name(string), type(string) Add remote url file for preview
<lf-ng-md-file-input lf-files="files" lf-api="api"></lf-ng-md-file-input>
<md-button class="md-raised md-warn" ng-click="api.removeAll()">remove all</md-button>
<script>
    ...
    $timeout(
        function(){
            $scope.api.addRemoteFile('http://shuyu.github.io/angular-material-fileinput/example/resources/sample.jpg','sample.jpg','image');
            $scope.api.addRemoteFile('http://shuyu.github.io/angular-material-fileinput/example/resources/sample.mp4','sample.mp4','video');
            $scope.api.addRemoteFile('http://shuyu.github.io/angular-material-fileinput/example/resources/sample.mp3','sample.mp3','audio');
            $scope.api.addRemoteFile('http://shuyu.github.io/angular-material-fileinput/example/resources/sample.pdf','sample.pdf','other');
        }
    )
    ...
</script>

Currently addRemoteFile only support 4 types include "image"、"video"、"audio" and "other". The file add by addRemoteFile API will also exist in lf-files array but with a property isRemote:true, so when you upload files, you should do one more job to check the isRemote is true or false, if true then should ignore it.

screensho 3

###OPTION

Name Description
browseIconCls Set class to browse icon
removeIconCls Set class to remove icon
captionIconCls Set class to caption icon
unknowIconCls Set class to unknow icon
<style>
	.myBrowse{
        background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDEyOCAxMjgiIGlkPSLQodC70L7QuV8xIiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAxMjggMTI4IiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48Zz48cG9seWdvbiBmaWxsPSIjQzdCMTNDIiBwb2ludHM9IjczLDQgMTksNCAxOSwxMjQgMTA5LDEyNCAxMDksNDAgICIvPjwvZz48ZyBvcGFjaXR5PSIwLjIiPjxwb2x5Z29uIGZpbGw9IiMwNzBCMEMiIHBvaW50cz0iNzMsNDAgMTA5LDQwIDczLDQgICIvPjwvZz48Zz48cGF0aCBkPSJNMTA5LDEyNS4ySDE5Yy0wLjcsMC0xLjItMC42LTEuMi0xLjJWNGMwLTAuNywwLjYtMS4yLDEuMi0xLjJoNTBjNi4yLDAsMTEuMiw1LDExLjIsMTEuMn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DAuNSwwLjksMC4zLDEuNCAgICBDMTA3LDM3LjgsMTA2LjUsMzguMSwxMDYsMzguMXogTTgwLjIsMzIuOEg5OWMwLjQsMCwwLjgsMCwxLjIsMC4xbC0yMC0yMGMwLDAuNCwwLjEsMC44LDAuMSwxLjJWMzIuOHoiIGZpbGw9IiMxRTFFMUUiLz48L2c+PC9nPjxnPjxnPjxjaXJjbGUgY3g9IjY0IiBjeT0iODkiIGZpbGw9IiNGRkZGRkYiIHI9IjUiLz48L2c+PGc+PGc+PHJlY3QgZmlsbD0iI0ZGRkZGRiIgaGVpZ2h0PSIyOCIgd2lkdGg9IjgiIHg9IjYwIiB5PSI1MCIvPjwvZz48L2c+PC9nPjwvc3ZnPg==);
    }
</style>

<script type="text/javascript">
	...
    $scope.option = {
        "browseIconCls":"myBrowse",
        "removeIconCls":"myRemove",
        "captionIconCls":"myCaption",
        "unknowIconCls":"myUnknow"
    }
    ...
</script>

<lf-ng-md-file-input lf-files="files" lf-option="option"></lf-ng-md-file-input>

Release History

  • v1.5.1
    • Fix fail due to missing injector.
  • v1.5.0
    • Massive code architecture change.
    • Add addRemoteFile api.
    • Add callback for removeFile.
    • Fix validation bug.
    • Fix browse button not work on Firefox
    • Deep check when file has same name.
    • lf-mimetype can work with "," ex: image/*,video/*.
  • v1.4.8
    • New api to remove file by name.
    • Fix preview bug.
  • v1.4.7
    • File with same name will override.
    • New attributes : lf-on-file-click.
  • v1.4.6
    • Fix IE click event.
  • v1.4.5
    • Fix drop event.
  • v1.4.4
    • Add progress attribute.
  • v1.4.3
    • Remove console.log calls.
  • v1.4.2
    • Add lf-capion attribute to customize file caption.
    • Fix bug when $compileProvider.debugInfoEnabled(false).
  • v1.4.1
    • Add MIME type validation.
    • Add aria-label.
  • v1.4.0
    • Add validation feature.
  • v1.3.1
    • Fix firefox upload button.
  • v1.3.0
    • Make template much compatible with angular material.
    • Remove angular-material-icons dependencies and Add new lf-option attribute to make icon changeable.
  • v1.2.0
    • New lf-api attribute bind to interaction with directive.
  • v1.1.0
    • New attributes : lf-drag-and-drop-label, lf-browse-label and lf-remove-label.
  • v1.0.0
    • Standard features.
  • v0.1.0
    • Initial release.

About

A Html input file enhance base on angular material to file input or file upload.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 42.2%
  • HTML 34.2%
  • CSS 23.6%