Created
May 25, 2012 09:26
-
-
Save goog/2786943 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $db = $.couch.db("test"); | |
$(function() { | |
$("#uploader").plupload({ | |
// General settings | |
runtimes : 'flash,html5,browserplus,silverlight,gears,html4', | |
url : 'http://192.168.0.20:5984/test/test', | |
max_file_size : '1000mb', | |
max_file_count: 20, // user can add no more then 20 files at a time | |
//chunk_size : '1mb', | |
//unique_names : true, | |
//multiple_queues : true, | |
file_data_name : "_attachments", | |
// Resize images on clientside if we can | |
resize : {width : 320, height : 240, quality : 90}, | |
// Rename files by clicking on their titles | |
rename: true, | |
// Sort files | |
sortable: true, | |
// Specify what files to browse for | |
filters : [ | |
{title : "Image files", extensions : "jpg,gif,png"}, | |
{title : "Zip files", extensions : "zip,avi"} | |
], | |
// Flash settings | |
flash_swf_url : 'js/plupload.flash.swf', | |
// Silverlight settings | |
silverlight_xap_url : 'js/plupload.silverlight.xap', | |
multipart : true , | |
multipart_params : { | |
description: "uploadedViaPlupload", | |
_rev: "6-bcce7b449dd984d79d8e715b6c32dfc5" | |
} | |
}); | |
// Client side form validation | |
var uploader = $('#uploader').plupload('getUploader'); | |
uploader.bind('BeforeUpload', function(up, file) { | |
alert("here"); | |
$db.saveDoc({ | |
users : 'all' | |
}, { | |
success : function(response) { | |
if(response.ok) { | |
up.settings.url = 'http://192.168.0.20:5984/test/' + response.id; | |
up.settings.multipart_params._rev = response.rev; | |
up.trigger("UploadFile", file); | |
} | |
} | |
}); | |
return false; | |
}); | |
$('form').submit(function(e) { | |
uploader.start(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment