Giter VIP home page Giter VIP logo

extjs-upload-widget's Introduction

File upload widget for Ext JS v4.x

Features

  • flexible and easily integratable
  • uses the native File API (HTML5)
  • allows selecting and uploading of multiple files at once
  • supports both raw PUT/POST upload and multipart upload
  • you can easily write and integrate your own upload mechanism, while preserving all (or most) of the UI functionality
  • displays upload progress
  • supports asynchronous (simultaneous) upload

Requirements

Installation

Clone the repository somewhere on your system and add the path with the prefix to Ext.Loader:

Ext.Loader.setPath({
    'Ext.ux.upload' : '/my/path/to/extjs-upload-widget/lib/upload'
});

Basic usage

In the most simple case, you can just open the dialog and pass the uploadUrl paramter:

var dialog = Ext.create('Ext.ux.upload.Dialog', {
    dialogTitle: 'My Upload Widget',
    uploadUrl: 'upload.php'
});

dialog.show();

Ext.ux.upload.Dialog is just a simple wrapper window. The core functionality is implemented in the Ext.uz.upload.Panel object, so you can implement your own dialog and pass the panel:

var myDialog = Ext.create('MyDialog', {
    items: [
        Ext.create('Ext.ux.upload.Panel', {
            uploadUrl: 'upload.php'
        });
    ]
});

Uploaders

The intention behind the uploaders implementation is to have the upload process decoupled from the UI as much as possible. This allows us to create alternative uploader implementations to serve our use case and at the same time, we don't need to touch the UI.

Currently, these uploaders are implemented:

  • ExtJsUploader (default) - uploads the file by sending the raw file data in the body of a XmlHttpRequest. File metadata are sent through request HTTP headers. Actually, the standard Ext.data.Connection object is used with a small tweak to allow progress reporting.
  • FormDataUploader - uploads the file through a XmlHttpRequest as if it was submitted with a form.

Each uploader requires different processing at the backend side. Check the public/upload.php file for the ExtJsUploader and the public/upload_multipart.php for the FormDataUploader.

Advanced usage

The default uploader is the ExtJsUploader. If you want to use an alternative uploader, you need to pass the uploader class name to the upload panel:

var panel = Ext.create('Ext.ux.upload.Panel', {
    uploader: 'Ext.ux.upload.uploader.FormDataUploader',
    uploaderOptions: {
        url: 'upload_multipart.php',
        timeout: 120*1000
    }
});

Or you can pass the uploader instance:

var panel = Ext.create('Ext.ux.upload.Panel', {
    uploader: Ext.create('Ext.ux.upload.uploader.FormDataUploader', {
        url: 'upload_multipart.php',
        timeout: 120*1000
    });
});

Running the example

Requirements:

  • web server with PHP support
  • Ext JS v4.x instance

Clone the repository and make the public directory accessible through your web server. Open the public/_config.php file and set the upload_dir option to point to a directory the web server can write to. If you just want to test the upload process and you don't really want to save the uploaded files, you can set the fake option to true and no files will be written to the disk.

The example index.html expects to find the Ext JS instance in the public/extjs directory. You can create a link to the instance or copy it there.

Online demo

Documentation

Other links

TODO

  • add more uploader implementations
  • add drag'n'drop support
  • improve documentation

License

Author

extjs-upload-widget's People

Contributors

ivan-novakov avatar

Stargazers

 avatar Geová Ramalho dos Santos avatar

Watchers

Loiane Groner avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.