Giter Site home page Giter Site logo

jquery-uploader's Introduction

#jQuery Uploader

The simplest configuration:

<script src="/jquery/jquery.js"></script>
<script src="/jquery-uploader/jquery-uploader.js"></script>
$('input[type="file"]').upload({
  url: '/upload'
});
<form enctype="multipart/form-data" action="/javascript.php" method="post">
   <input type="file" name="file"  multiple="multiple"/>
   <div data-jq-upload-error></div>
   <div data-jq-upload-preview></div>
</form>

#jQuery Uploader Options

$('input[type="file"]').upload({
   url: '/', //The url where the file will be sent to
   preview: { 
       selector: '[data-jq-upload-preview]', //Selector of item where preview will be displayed
       width: 400, //Width of preview image
       height: 200 //Height or preview image
   },
   trigger: {
       type: 'button', //Available options ['button', 'dropzone']
       attributes: {                                   // ['id', 'class', 'style'...]
           id: 'button-id', //Trigger id attribute 
           class: 'button-class', //Trigger class attribute
           style: 'width:100px' //Trigger style attribute
           ... //You can add whatever attribute you want to
       }
   },
   selectFileText: 'Select file from your hard drive', //Text displayed inside button or dropzone
   timeout: 8000, //Timeout of ajax request
   maxFiles: 4, //Max available number of uploaded files
   maxSize: '80000000', //Max size of single file in bytes
   allowedMimeTypes: ['image/jpeg'], //Allowed mimetypes of uploaded files
   allowedExtensions: ['jpg'], //Allowed extensions of uploaded files
   error: {
       selector: '[data-jq-upload-error]', //Selector where errors will be set when appear
       attributes: { //Attributes of error html element
           style: 'border:1px solid red; color:red;'
           ... //You can add whatever attribute you want to
       }
   },
   buttons: { 
       upload: {
           text: 'Upload a file' //Text of upload button,
           attributes: {
               id: 'button-upload-id',
               class: 'button-upload-class',
               ... //You can add whatever attribute you want to
           },
           onClick: function(event, config) {} //It will be trigered on click for upload button
       },
       cancel: {
           text: 'Remove a file' //Text of remove button,
           attributes: {
               id: 'button-cancel-id',
               class: 'button-cancel-class',
               ... //You can add whatever attribute you want to
           },
           onClick: function(event, config) {} //It will be trigered on click for cancel button.
       },
       uploadAll: {
           text: 'Upload all files',
           attributes: {
               class: 'btn btn-form-submit'
           }
       }       
   },
   upload: {
       onAbort: function(event, config) {}, //Function that is triggered when request is aborted
       onError: function(event, config) {}, //Function that is triggered when request upload failed
       onTimeout: function(event, config) {}, //Function that is triggered after timeout
       onSuccess: function(event, config) {}, //Function that is triggered after successfully uploading
       onLoadEnd: function(event, config) {}, //Function that is triggered when request is finished
       onProgress: function(event, config) {}, //Function that is triggered during upload 
       onLoadStart: function(event, config) {} //Function that is triggered when upload starts
   }
});

jquery-uploader's People

Contributors

adrianmalik avatar arius86 avatar

Watchers

 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.