Uploader

Example

Code

<fine-uploader id='myUploader1'>
</fine-uploader>

<script type="text/javascript">
  fine.ready(function(e) {
    var el = document.getElementById('myUploader1');
    el.setConfig({
      maxHeight: '300px',
      target: '../../includes/upload.php',
      clientEvents: {
        'before-file-added': 'onClientBeforeFileAdded',
        'files-added': 'onClientFilesAdded',
        'before-file-removed': 'onClientBeforeFileRemoved',
        'before-file-resumed': 'onClientBeforeFileResumed',
        'file-resumed': 'onClientFileResumed',
        'before-file-paused': 'onClientBeforeFilePaused',
        'file-paused': 'onClientFilePaused',
        'file-progress': 'onClientFileProgress',
        'file-success': 'onClientFileSuccess',
        'file-error': 'onClientFileError',
        complete: 'onClientProgress',
        progress: 'onClientProgress',
        error: 'onClientError',
        start: 'onClientStart',
      }
    });
    fine.addListener(el, 'before-file-added', onBeforeFileAdded);
    fine.addListener(el, 'files-added', onFilesAdded);
    fine.addListener(el, 'before-file-removed', onBeforeFileRemoved);
    fine.addListener(el, 'before-file-resumed', onBeforeFileResumed);
    fine.addListener(el, 'file-resumed', onFileResumed);
    fine.addListener(el, 'before-file-paused', onBeforeFilePaused);
    fine.addListener(el, 'file-paused', onFilePaused);
    fine.addListener(el, 'file-progress', onFileProgress);
    fine.addListener(el, 'file-success', onFileSuccess);
    fine.addListener(el, 'file-error', onFileError);
    fine.addListener(el, 'complete', onComplete);
    fine.addListener(el, 'progress', onProgress);
    fine.addListener(el, 'error', onError);
    fine.addListener(el, 'start', onStart);
    
    var order = 0;
    var logDiv = fine.get('#log');
      
    function log(msg, obj) {
      order += 1;
      logDiv.innerText += order + '. ' + msg + '\n';
      logDiv.scrollTop = logDiv.scrollHeight;
      console.log(msg, obj ? obj : '');
      console.log('');
    }
    
    function onBeforeFileAdded(e) {
      log('myUploader1 before file added!', e.detail.file);
    }
    
    function onClientBeforeFileAdded(arg) {
      log('Client myUploader1 before file added!', arg.file);
    }
    
    //...
  });
</script>