More demos

Want more than basic stuff? See here!

Manually Trigger Uploads

The default behavior of Fine Uploader is to immediately attempt to upload files as they are selected. One option allows you to simply queue all files, and then start uploading at a later time by calling uploadStoredFiles() on your Fine Uploader instance.

Since we need to catch click events on an HTML element, we will be using jQuery to handle events and selectors for the sake of simplicity.

You can obviously take it further with the optional jQuery wrapper demos.

Upload now
<div id="manual-fine-uploader"></div>
<div id="triggerUpload" class="btn btn-primary" style="margin-top: 10px;">
  <i class="icon-upload icon-white"></i> Upload now
</div>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="client/fineuploader.js"></script>
<script src="client/js/jquery-plugin.js"></script>
<script>
  $(document).ready(function() {
    var manualuploader = $('#manual-fine-uploader').fineUploader({
      request: {
        endpoint: 'server/handleUploads'
      },
      autoUpload: false,
      text: {
        uploadButton: '<i class="icon-plus icon-white"></i> Select Files'
      },
      debug: true
    });

    $('#triggerUpload').click(function() {
      manualuploader.fineUploader('uploadStoredFiles');
    });
  });
</script>

See Server Failure Messages

If your server returns a response that includes a reason property, such as {"error": "unsupported file type"} you can display the error message next to the failed file.

<div id="failed-fine-uploader"></div>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="client/fineuploader.js"></script>
<script src="client/js/jquery-plugin.js"></script>
<script>
  $(document).ready(function() {
    $('#failed-fine-uploader').fineUploader({
      request: {
        endpoint: 'server/handleUploads'
      },
      failedUploadTextDisplay: {
        mode: 'custom',
        maxChars: 40,
        responseProperty: 'error',
        enableTooltip: true
      },
      debug: true
    });
  });
</script>

Various Options

There are various options available to you when using Fine Uploader. In this demo, we've used a small subset of these options. To see all available options and their usage, please refer to Fine Uploader documentation on the Github repository.

We are implementing the following options in this demo:

  • custom upload button text,
  • restriction to one file upload/selection at once (may not select multiple files),
  • restriction to jpeg, jpg, and txt files,
  • restriction to a maximum file size of 50 kB,
  • custom error display handler instead of the default alert box.
<div id="restricted-fine-uploader"></div>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="client/fineuploader.js"></script>
<script src="client/js/jquery-plugin.js"></script>
<script>
  $(document).ready(function() {
    $('#restricted-fine-uploader').fineUploader({
      request: {
        endpoint: 'server/success.html'
      },
      multiple: false,
      validation: {
        allowedExtensions: ['jpeg', 'jpg', 'txt'],
        sizeLimit: 51200 // 50 kB = 50 * 1024 bytes
      },
      text: {
        uploadButton: 'Click or Drop'
      },
      showMessage: function(message) {
        // Using Bootstrap's classes
        $('#restricted-fine-uploader').append('<div class="alert alert-error">' + message + '</div>');
      },
      debug: true
    });
  });
</script>

Display Image Thumbnails

In this demo, we've used the onComplete callback to display thumbnails of the uploaded images after they have been uploaded to the server.

Since the demos do not actually upload your files, the thumbnail is fake. We hope you like it though :)

This uploader is also restricted in

  • size (50 kB)
  • in concurrent downloads (only one at once),
  • in allowed extensions (jpeg, jpg, gif, and png)
<div id="thumbnail-fine-uploader"></div>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="client/fineuploader.js"></script>
<script src="client/js/jquery-plugin.js"></script>
<script>
  $(document).ready(function() {
    $('#thumbnail-fine-uploader').fineUploader({
      request: {
        endpoint: 'server/success.html'
      },
      multiple: false,
      validation: {
        allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
        sizeLimit: 51200 // 50 kB = 50 * 1024 bytes
      },
      text: {
        uploadButton: 'Click or Drop'
      },
      debug: true
    }).on('complete', function(event, id, fileName, responseJSON) {
      if (responseJSON.success) {
        $(this).append('<img src="img/success.jpg" alt="' + fileName + '">');
      }
    });
  });
</script>

Limit Number of Uploaded Files

In this demo, we are using both the onSubmit and the onComplete callbacks to handle a file counter.

This uploader is also restricted in

  • size (50 kB)
  • in allowed extensions (jpeg, jpg, gif, and png)

If you're yet to process the uploads (to store in a database for instance), it's quite easy to customize it even more in order to provide handles to delete a given uploaded file. In fact, it wouldn't hard delete the file on the server, just delete the link in the DOM.

<div id="filelimit-fine-uploader"></div>

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="client/fineuploader.js"></script>
<script src="client/js/jquery-plugin.js"></script>
<script>
  var fileCount = 0;
  var addedFiles = 0;
  var fileLimit = 3;

  $(document).ready(function() {
    $('#filelimit-fine-uploader').fineUploader({
      request: {
        endpoint: 'server/success.html'
      },
      validation: {
        allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
        sizeLimit: 51200 // 50 kB = 50 * 1024 bytes
      },
      debug: true
    }).on('submit', function(event, id, fileName) {
      fileCount ++;
      if(fileCount > fileLimit) {
        $('#filelimit-fine-uploader .qq-upload-button').hide();
        $('#filelimit-fine-uploader .qq-upload-drop-area').hide();
        return false;
      }
    }).on('cancel', function(event, id, fileName) {
      fileCount --;
      if(fileCount <= fileLimit) {
        $('#filelimit-fine-uploader .qq-upload-button').show();
      }
    }).on('complete', function(event, id, fileName, responseJSON) {
      if (responseJSON.success) {
        addedFiles ++;
        if(addedFiles >= fileLimit) {
          $('#filelimit-fine-uploader .qq-upload-button').hide();
          $('#filelimit-fine-uploader .qq-upload-drop-area').hide();
        }
      }
    });
  });
</script>