custom.html 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  5. <title>Plupload - Custom example</title>
  6. <!-- production -->
  7. <script type="text/javascript" src="../js/plupload.full.min.js"></script>
  8. <!-- debug
  9. <script type="text/javascript" src="../js/moxie.js"></script>
  10. <script type="text/javascript" src="../js/plupload.dev.js"></script>
  11. -->
  12. </head>
  13. <body style="font: 13px Verdana; background: #eee; color: #333">
  14. <h1>Custom example</h1>
  15. <p>Shows you how to use the core plupload API.</p>
  16. <div id="filelist">Your browser doesn't have Flash, Silverlight or HTML5 support.</div>
  17. <br />
  18. <div id="container">
  19. <a id="pickfiles" href="javascript:;">[Select files]</a>
  20. <a id="uploadfiles" href="javascript:;">[Upload files]</a>
  21. </div>
  22. <br />
  23. <pre id="console"></pre>
  24. <script type="text/javascript">
  25. // Custom example logic
  26. var uploader = new plupload.Uploader({
  27. runtimes : 'html5,flash,silverlight,html4',
  28. browse_button : 'pickfiles', // you can pass in id...
  29. container: document.getElementById('container'), // ... or DOM Element itself
  30. url : 'upload.php',
  31. flash_swf_url : '../js/Moxie.swf',
  32. silverlight_xap_url : '../js/Moxie.xap',
  33. filters : {
  34. max_file_size : '10mb',
  35. mime_types: [
  36. {title : "Image files", extensions : "jpg,gif,png"},
  37. {title : "Zip files", extensions : "zip"}
  38. ]
  39. },
  40. init: {
  41. PostInit: function() {
  42. document.getElementById('filelist').innerHTML = '';
  43. document.getElementById('uploadfiles').onclick = function() {
  44. uploader.start();
  45. return false;
  46. };
  47. },
  48. FilesAdded: function(up, files) {
  49. plupload.each(files, function(file) {
  50. document.getElementById('filelist').innerHTML += '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></div>';
  51. });
  52. },
  53. UploadProgress: function(up, file) {
  54. document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
  55. },
  56. Error: function(up, err) {
  57. document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
  58. }
  59. }
  60. });
  61. uploader.init();
  62. </script>
  63. </body>
  64. </html>