Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Plupload Examples: Chunking
<!DOCTYPE html>
<html xmlns="" dir="ltr">
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Plupload - Getting Started: Chunking</title>
<script type="text/javascript" src="js/plupload.full.min.js"></script>
<ul id="filelist"></ul>
<br />
<div id="container">
<a id="browse" href="javascript:;">[Browse...]</a>
<a id="start-upload" href="javascript:;">[Start Upload]</a>
<br />
<pre id="console"></pre>
<script type="text/javascript">
var uploader = new plupload.Uploader({
browse_button: 'browse', // this can be an id of a DOM element or the DOM element itself
url: 'upload.php',
chunks_size: '200kb',
max_retries: 3
uploader.bind('FilesAdded', function(up, files) {
var html = '';
plupload.each(files, function(file) {
html += '<li id="' + + '">' + + ' (' + plupload.formatSize(file.size) + ') <b></b></li>';
document.getElementById('filelist').innerHTML += html;
uploader.bind('UploadProgress', function(up, file) {
document.getElementById('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
uploader.bind('ChunkUploaded', function(up, file, info) {
// do some chunk related stuff
uploader.bind('Error', function(up, err) {
document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
document.getElementById('start-upload').onclick = function() {

This comment has been minimized.

Copy link

@filmo filmo commented Aug 15, 2013

What is 'ChunkUploaded' envisioned to do? Is is necessary to handle failed chunk uploads here (via max_retries) or is this handled transparently in the background. Or is this just to an entry to providing UI feedback for successfully processed server side chunks and it's response ?

I guess what I'm saying is "What would be a example usage of ChunkUploaded?"


This comment has been minimized.

Copy link

@davidchase davidchase commented Oct 4, 2013



This comment has been minimized.

Copy link
Owner Author

@jayarjo jayarjo commented Jan 16, 2014

Providing UI feedback I guess would be a best example. Handler for ChunkUploaded gets HTTP status and response text if available. One could send some checksum info from server and compare it to the one calculated on client-side for example. Potentially it can become more useful in conjunction with BeforeChunkUpload (moxiecode/plupload#809), that we are going to add in 2.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment