friendica-addons/js_upload/file-uploader
ImgBotApp 1ba2da2f31 [ImgBot] optimizes images
*Total -- 800.45kb -> 573.62kb (28.34%)

/dav/colorpicker/arrow.png -- 26.66kb -> 0.39kb (98.53%)
/jappixmini/jappix/img/wait/wait-medium.png -- 4.03kb -> 0.68kb (83.1%)
/xmpp/converse/css/images/bitcoin_qr_code.png -- 4.12kb -> 1.07kb (73.95%)
/dav/SabreDAV/lib/Sabre/DAV/Browser/assets/icons/principal.png -- 5.35kb -> 1.60kb (70.15%)
/sniper/70x45.jpg -- 15.15kb -> 5.14kb (66.03%)
/dav/SabreDAV/lib/Sabre/DAV/Browser/assets/icons/card.png -- 5.56kb -> 1.91kb (65.65%)
/dav/SabreDAV/lib/Sabre/DAV/Browser/assets/icons/file.png -- 2.77kb -> 1.03kb (62.99%)
/sniper/32x32.jpg -- 13.58kb -> 5.18kb (61.87%)
/dav/SabreDAV/lib/Sabre/DAV/Browser/assets/icons/addressbook.png -- 7.06kb -> 2.76kb (60.98%)
/sniper/60x60.jpg -- 19.07kb -> 8.73kb (54.24%)
/sniper/80x70.jpg -- 5.10kb -> 2.33kb (54.2%)
/dav/SabreDAV/lib/Sabre/DAV/Browser/assets/icons/collection.png -- 3.39kb -> 1.60kb (52.76%)
/dav/SabreDAV/lib/Sabre/DAV/Browser/assets/icons/parent.png -- 3.39kb -> 1.60kb (52.76%)
/sniper/125x125.jpg -- 30.95kb -> 14.77kb (52.28%)
/sniper/80x80hotshotsniper.jpg -- 23.20kb -> 11.29kb (51.33%)
/js_upload/file-uploader/tests/jquery-ui/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png -- 4.32kb -> 2.12kb (51.03%)
/smilies_adult/icons/drunk.gif -- 0.63kb -> 0.31kb (50.46%)
/sniper/100x100.jpg -- 29.77kb -> 15.36kb (48.41%)
/smilies_adult/icons/bong.gif -- 1.82kb -> 0.96kb (47%)
/xmpp/converse/css/images/user.png -- 1.66kb -> 0.93kb (44.08%)
/sniper/150x150.jpg -- 42.74kb -> 23.97kb (43.92%)
/dav/jqueryui/images/ui-bg_gloss-wave_35_f6a828_500x100.png -- 3.67kb -> 2.12kb (42.37%)
/dav/wdcal/css/images/calendar/load-bg.png -- 1.02kb -> 0.60kb (40.98%)
/sniper/180x135.jpg -- 10.22kb -> 6.09kb (40.45%)
/sniper/80x60.jpg -- 7.70kb -> 4.84kb (37.11%)
/ifttt/ifttt.png -- 7.55kb -> 4.79kb (36.51%)
/smiley_pack/icons/sad/crying.png -- 1.23kb -> 0.79kb (35.35%)
/sniper/75x57.jpg -- 8.10kb -> 5.25kb (35.17%)
/sniper/70x60.jpg -- 7.98kb -> 5.22kb (34.59%)
/dav/SabreDAV/lib/Sabre/DAV/Browser/assets/icons/calendar.png -- 4.29kb -> 2.82kb (34.09%)
/sniper/81x67.jpg -- 9.58kb -> 6.42kb (32.96%)
/dav/colorpicker/screenshot.png -- 2.03kb -> 1.38kb (32.19%)
/sniper/73x80.jpg -- 9.23kb -> 6.30kb (31.79%)
/sniper/100x80.jpg -- 12.23kb -> 8.37kb (31.54%)
/sniper/100x75.jpg -- 11.73kb -> 8.08kb (31.1%)
/sniper/120x90hotshotsniper.jpg -- 15.74kb -> 11.00kb (30.15%)
/sniper/140x90.jpg -- 17.28kb -> 12.29kb (28.83%)
/sniper/300x200.jpg -- 16.08kb -> 11.81kb (26.53%)
/sniper/300x300.jpg -- 19.07kb -> 14.30kb (25.03%)
/sniper/335x185.jpg -- 14.99kb -> 11.36kb (24.18%)
/dav/wdcal/css/images/calendar/bubble_combined.png -- 1.92kb -> 1.52kb (20.87%)
/sniper/250x180.jpg -- 38.65kb -> 31.69kb (18%)
/smileybutton/view/smoothly.png -- 0.95kb -> 0.79kb (16.79%)
/xmpp/converse/css/images/overlay.png -- 47.50kb -> 39.89kb (16.01%)
/smileybutton/view/vier.png -- 0.92kb -> 0.78kb (14.57%)
/smiley_pack/icons/food/cake.gif -- 0.65kb -> 0.56kb (13.77%)
/twitter/vendor/abraham/twitteroauth/tests/kitten.jpg -- 210.64kb -> 202.94kb (3.66%)
/smiley_pack/icons/fight/gangs.gif -- 1.71kb -> 1.65kb (2.98%)
/xmpp/converse/css/images/header.jpg -- 30.31kb -> 29.41kb (2.96%)
/statusnet/signinwithstatusnet.png -- 5.67kb -> 5.52kb (2.6%)
/smiley_pack/icons/respect/bravo.gif -- 0.74kb -> 0.72kb (2.5%)
/dav/wdcal/css/images/icons/mtgrsp-decline.gif -- 0.30kb -> 0.29kb (1.32%)
/smiley_pack/icons/fight/dead.gif -- 0.16kb -> 0.16kb (1.2%)
/catavatar/avatars/fur_5.png -- 6.58kb -> 6.50kb (1.08%)
/dav/wdcal/css/images/icons/appt.gif -- 0.56kb -> 0.56kb (1.04%)
/catavatar/avatars/fur_6.png -- 5.70kb -> 5.65kb (0.74%)
/smiley_pack/icons/fight/army.gif -- 2.95kb -> 2.93kb (0.69%)
/dav/wdcal/css/images/icons/mtgrsp-tent.gif -- 0.29kb -> 0.29kb (0.67%)
/smiley_pack/icons/devilangel/angel.gif -- 0.30kb -> 0.30kb (0.64%)
/smiley_pack/icons/confused/shrug.gif -- 0.18kb -> 0.18kb (0.54%)
/dav/wdcal/css/images/icons/calwrkwk.gif -- 0.38kb -> 0.37kb (0.52%)
/smiley_pack/icons/fight/crusader.gif -- 0.39kb -> 0.39kb (0.5%)
/catavatar/avatars/body_12.png -- 12.70kb -> 12.65kb (0.42%)
/smiley_pack/icons/happy/cloud9.gif -- 0.26kb -> 0.26kb (0.38%)
2018-07-14 02:28:43 -04:00
..
client some files were executable, now they are not 2017-12-07 14:26:26 +01:00
server some files were executable, now they are not 2017-12-07 14:26:26 +01:00
tests [ImgBot] optimizes images 2018-07-14 02:28:43 -04:00
gpl-2.0.txt some files were executable, now they are not 2017-12-07 14:26:26 +01:00
license.txt some files were executable, now they are not 2017-12-07 14:26:26 +01:00
readme.md Update strings 2018-01-20 11:01:59 -05:00

readme.md

This addon uses XHR for uploading multiple files with progress-bar in FF3.6+, Safari4+, Chrome and falls back to hidden iframe based upload in other browsers, providing good user experience everywhere.

Features

  • multiple file select, progress-bar in FF, Chrome, Safari
  • drag-and-drop file select in FF, Chrome
  • uploads are cancellable
  • no external dependencies
  • doesn't use Flash
  • fully working with https
  • keyboard support in FF, Chrome, Safari
  • tested in IE7,8; Firefox 3,3.6,4; Safari4,5; Chrome; Opera10.60;

License

This addon is open sourced under GNU GPL 2 or later. If this license doesn't suit you mail me at andrew (at) valums.com.

Please donate if you are willing to support the further development of file upload addon.

Known Issues

Addon breaks back button functionality in Opera.

Getting started

The fileuploader.js contains two classes that are meant to be used directly. If you need a complete upload widget (from demo) to quickly drop into your current design, use qq.FileUploader.

If you want to customize uploader, by using a different looking file list or change the behaviour or functionality use qq.FileUploaderBasic.

The difference between them is that qq.FileUploader provides a list of files, drag-and-drop, but qq.FileUploaderBasic only creates button and handles validation. Basic uploader is easier extendable, and doesn't limit possible customization.

qq.FileUploader extends qq.FileUploaderBasic, so that all the options present in the basic uploader also exist in the full widget.

qq.FileUploader - Setting up full upload widget

Include fileuploader.js and fileuploader.css into your page. Create container element.

<div id="file-uploader">       
    <noscript>          
        <p>Please enable JavaScript to use file uploader.</p>
        <!-- or put a simple form for upload here -->
    </noscript>         
</div>

Initialize uploader when the DOM is ready. Change the action option. For example ../server/php.php for the default folder structure. In the server folder you will find examples for different platforms. If you can't find the one you need, check the readme.txt in the same folder.

var uploader = new qq.FileUploader({
    // pass the dom node (ex. $(selector)[0] for jQuery users)
    element: document.getElementById('file-uploader'),
    // path to server-side upload script
    action: '/server/upload'
}); 

Options of both classes

// url of the server-side upload script, should be on the same domain
action: '/server/upload',
// additional data to send, name-value pairs
params: {},

// validation    
// ex. ['jpg', 'jpeg', 'png', 'gif'] or []
allowedExtensions: [],        
// each file size limit in bytes
// this option isn't supported in all browsers
sizeLimit: 0, // max size   
minSizeLimit: 0, // min size

// set to true to output server response to console
debug: false,

// events         
// you can return false to abort submit
onSubmit: function(id, fileName){},
onProgress: function(id, fileName, loaded, total){},
onComplete: function(id, fileName, responseJSON){},
onCancel: function(id, fileName){},

messages: {
    // error messages, see qq.FileUploaderBasic for content            
},
showMessage: function(message){ alert(message); }        

Instance methods

  • setParams(newParams)

Changing alert/messages to something more user friendly

If you limited file types and max size, you will probably want to change the default alert and messages as you see fit, this is possible using showMessage callback and messages option.

Sending additional params

To add a parameter that will be passed as a query string with each upload use params option.

var uploader = new qq.FileUploader({
    element: document.getElementById('file-uploader'),
    action: '/server-side.upload',
    // additional data to send, name-value pairs
    params: {
        param1: 'value1',
        param2: 'value2'
    }
});

To change params based on the state of your app, use

uploader.setParams({
   anotherParam: 'value' 
});

It can be nicely used in onSubmit callback.

Troubleshooting

If you can't get the uploader to work, please try the following steps before asking for help.

If the upload doesn't complete, saying failed.

  • Set the debug option of the FileUploader to true.
  • Open the page where you have a FileUploader.
  • Open developer console in your browser.
  • Try to upload the file. You should see a server serponse.

It should be {success:true} for completed requests. If it's not, then you have a problem with your server-side script.

Contributors

Thanks to everybody who contributed, either by sending bug reports or donating. And special thanks to:

John Yeary
Sidney Maestre
Patrick Pfeiffer
Sean Sandy (SeanJA)
Andy Newby
Ivan Valles