v1.x - Core API - Bundled example

author(s): Davit Barbakadze

by Liu David

HTML

<script src="https://rawgithub.com/moxiecode/plupload/1.x/js/plupload.full.js"></script>
<h1>Custom example</h1>

<p>Shows you how to use the core plupload API.</p>

<div id="filelist">Your browser doesn't have Flash, Silverlight or HTML5 support.</div>
<br />

<div id="container">
    <a id="pickfiles" href="javascript:;">[Select files]</a> 
    <a id="uploadfiles" href="javascript:;">[Upload files]</a>
    <a id="btn2" href="javascript:;">button 2</a>
</div>

<br />
<pre id="console"></pre>

JavaScript

// jQuery not really required, it's here to overcome an inability to pass configuration options to the fiddle remotely
$(document).ready(function() {
	// Custom example logic
	function $(id) {
		return document.getElementById(id);	
	}

	var uploader = new plupload.Uploader({
		runtimes : 'html5,flash,silverlight,html4',
		browse_button : 'pickfiles',
		container: 'container',
		max_file_size : '10mb',
		
		// Fake server response here 
		// url : '../upload.php',
		url: "/echo/json",

		flash_swf_url : 'http://rawgithub.com/moxiecode/plupload/1.x/js/plupload.flash.cors.swf',
		silverlight_xap_url : 'http://rawgithub.com/moxiecode/plupload/1.x/js/plupload.silverlight.cors.xap',
		filters : [
			{title : "Image files", extensions : "jpg,gif,png"},
			{title : "Zip files", extensions : "zip"}
		],

		init: {
			PostInit: function() {
				$('filelist').innerHTML = '';

				$('uploadfiles').onclick = function() {
					uploader.start();
					return false;
				};
			},

			FilesAdded: function(up, files) {
				plupload.each(files, function(file) {
					$('filelist').innerHTML += '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></div>';
				});
			},

			UploadProgress: function(up, file) {
				$(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
			},

			Error: function(up, err) {
				$('console').innerHTML += "\nError #" + err.code + ": " + err.message;
			}
		}
	});

	uploader.init();
    
    uploader.disableBrowse(false);
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    var uploader2 = new plupload.Uploader({
		runtimes : 'html5,flash,silverlight,html4',
		browse_button : 'btn2',
		container: 'container',
		max_file_size : '10mb',
		
		// Fake server response here 
		// url : '../upload.php',
		url: "/echo/json",

		flash_swf_url : 'http://rawgithub.com/moxiecode/plupload/1.x/js/plupload.flash.cors.swf',
		silverlight_xap_url :...