Skip to content
JavaScript upload handler with easy ui customization
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
dist
src
.gitignore
Gruntfile.js
README.md
bower.json
package.json

README.md

Upload.js

Fully customizable frontend uploader component. UI you are making yourself.

Quick example

$('#fileInput').uploader({
    transport: 'xhr',
    uploadHandlerUrl: '/upload',
    progressHandlerUrl: '/progress',
    uploadHandlerParams: function() {
        return {additionalParam: 'additionalValue'};
    },
    onsuccess: function(response) {
        $('#status').html(response);
    },
    onerror: function(response) {
        $('#status').html(response);
    },
    onprogress: function(loaded, total) {
        // Twitter bootstrap progress
        var persents = Math.ceil(loaded / total * 100);
        var $progress = $('#fileInput')
            .closest('form')
            .find('.progress')
            .show();

        $progress.find('.progress-bar')
            .css({width: persents + "%"})
            .text(persents + '%');

        if(100 === persents) {
            setTimeout(function() {
                $progress.hide();
                $progress.find('.progress-bar')
                    .css({width: "0%"})
                    .text('0%');
            }, 800);
        }
    },
    responseType: 'html'
});

Sandbox

Backend and frontend may be tested in sandbox https://github.com/sokil/php-upload-sandbox. Clone repo and start server.

Backends

Language Library
PHP Library https://github.com/sokil/php-upload
Symfony Bundle https://github.com/sokil/FileStorageBundle
Something went wrong with that request. Please try again.