Small Drag & Drop To Upload Plugin - jQuery simple-upload

File Size: 16.5 KB
Views Total: 29880
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Small Drag & Drop To Upload Plugin - jQuery simple-upload

simple-upload is a lightweight, user-friendly, AJAX-enabled file uploader plugin that supports drag'n'drop, file validation, upload progress bar, AJAX form submit, etc.

The plugin provides a basic file upload experience on your web application while leaving the styling up to you.

How to use it:

1. Create a normal file input on the webpage.

<input type="file" name="file" id="basic">

2. The plugin also supports multiple file upload.

<input type="file" name="file" multiple="true" id="basic">

3. Create a drop zone where the user can add files to the upload queue via drag and drop.

<div id="basic_drop_zone" class="dropZone">
  <div>Drop files here</div>

4. Create a 'progress' container to hold the progress bar while uploading files to the server.

<div id="basic_progress"></div>

5. Create a 'message' container to hold the feedback messages.

<div id="basic_message"></div>

6. Initialize the plugin and done.

  dropZone: '#basic_drop_zone',
  progress: '#basic_progress'

7. Determine how you'd like to upload the file(s).


  // url to send the data
  url: '',

  // submit method
  method: 'post',

  // set object
  params: {
    'KEY': 'VALUE'
  // or set callback
  params: function() {
    return { 'KEY': 'VALUE' };

  ajax: {
    headers: {
    dataType: 'application/json',
    timeout: 0,
    async: true

8. Validate the file(s) to upload on the client-side. All possible validators:

  • The max number of files.
  • File size.
  • Extension name.
  • Mime type.
  • Custom validation rule.
function validate(files) {
  var passed = []
  for (var i=0; i<files.length; i++) {
    if (files[i].name == 'test.txt') {
      alert("can't upload test.txt");
    } else {
  return passed;

  maxFileNum: 4,
  maxFileSize: 100,
  allowedFileName: /\.txt$/,
  allowedMimeType: /^text\//,
  validator: validate

9. Available functions to handle the upload events.

$('#basic').simpleUpload().on('upload:before', function(e, files) {
}).on('upload:after', function(e, files) {
}).on('upload:start', function(e, file, i) {
  console.log('start ' + i);
}).on('upload:progress', function(e, file, i, loaded, total) {
  console.log('progress ' + i + ' ' + loaded + '/' + total);
}).on('upload:end', function(e, file, i) {
  console.log('end ' + i);
}).on('upload:done', function(e, file, i) {
  console.log('done ' + i);
  $('#basic_message').prepend('<p>done: ' + + '</p>');
}).on('upload:fail', function(e, file, i) {
  console.log('fail ' + i);
  $('#basic_message').prepend('<p>fail: ' + + '</p>');


v0.4.0 (2020-07-12)

  • Add ajax option

v0.3.0 (2019-10-21)

  • Bundle css with js.

This awesome jQuery plugin is developed by kanety. For more Advanced Usages, please check the demo page or visit the official website.