Repository navigation
Basic plugin
everclear edited this page May 4, 2012
·
48 revisions
The plugin download package comes with a complete user interface based on Bootstrap. There is also a version available for jQuery UI.
However, if you want to build your own user interface, it is possible to use only the basic plugin version and a minimal setup.
The following is an alternative to index.html with only the minimal requirements and a simple done callback handler (see API and Options on how to use the different options and callbacks):
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>jQuery File Upload Example</title> </head> <body> <input id="fileupload" type="file" name="files[]" data-url="server/php/" multiple> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script src="js/vendor/jquery.ui.widget.js"></script> <script src="js/jquery.iframe-transport.js"></script> <script src="js/jquery.fileupload.js"></script> <script> $(function () { $('#fileupload').fileupload({ dataType: 'json', done: function (e, data) { $.each(data.result, function (index, file) { $('<p/>').text(file.name).appendTo(document.body); }); } }); }); </script> </body> </html>
Include the following additional scripts (include jquery.fileupload-fp.js after jquery.fileupload.js):
<script src="http://blueimp.github.com/JavaScript-Load-Image/load-image.min.js"></script> <script src="http://blueimp.github.com/JavaScript-Canvas-to-Blob/canvas-to-blob.min.js"></script> <script src="js/jquery.fileupload-fp.js"></script>
If you don't override the add callback option, you'll have image resizing functionality automatically. Else, you can make use of the process API like this:
$('#fileupload').fileupload({ /* ... */ add: function (e, data) { $(this).fileupload('process', data).done(function () { data.submit(); }); } });