Topic: upload immediately
is there option to enable upload immediately after choosing the files?
Plupload Forum → General discussion → upload immediately
is there option to enable upload immediately after choosing the files?
Nope, but it would be easy for you to add a event listener for it and start the upload of the queue.
New UI Widget now has a special option for this, but it is not yet released. But everything it does, like Spocke said, is - binds itself to a FilesAdded event and starts uploading manually.
Here is my code for this :
<div id="container">
<a id="pickFiles" href="#"><img src="img/picture_add.png" /></a>
</div>
<script type="text/javascript">
var uploader = new plupload.Uploader({
runtimes : 'flash',
browse_button : 'pickfiles',
container : 'container',
max_file_size : '10mb',
url : '<?php echo $me ?>',
flash_swf_url : '/plupload/js/plupload.flash.swf',
filters : [ {title : "Image files", extensions : "jpg,gif,png"} ],
resize : {width : 320, height : 240, quality : 90}
});
uploader.bind('FilesAdded', function(up, files) {
up.start();
});
uploader.bind('FileUploaded', function(up, file) {
alert("File uploaded");
});
uploader.init();
</script>
Should work OK in theory, but fails in practice : it only starts uploading after a second file has been added to the queue.
Maybe a developer can be of further help ?
You must call the init function between creating your instance of plupload and binding your FilesAdded callback.
I also have a call to up.refresh before calling start in my FilesAdded callback as well. I'm not sure if this is still needed for any of the runtimes but at one time it was needed (for flash maybe??). Anyway it doesn't hurt - you can try it with or without and make up your own mind.
See below for my suggested changes.
Mike
<div id="container">
<a id="pickFiles" href="#"><img src="img/picture_add.png" /></a>
</div>
<script type="text/javascript">
var uploader = new plupload.Uploader({
runtimes : 'flash',
browse_button : 'pickfiles',
container : 'container',
max_file_size : '10mb',
url : '<?php echo $me ?>',
flash_swf_url : '/plupload/js/plupload.flash.swf',
filters : [ {title : "Image files", extensions : "jpg,gif,png"} ],
resize : {width : 320, height : 240, quality : 90}
});
uploader.init; // ** Init the uploader.
uploader.bind('FilesAdded', function(up, files) {
up.refresh(); // ** this seems to show up in lots of examples as well.
up.start();
});
uploader.bind('FileUploaded', function(up, file) {
alert("File uploaded");
});
uploader.init();
</script>
Thanks for the code made a huge difference in the upload time.
Plupload Forum → General discussion → upload immediately
You are not logged in. Please login or register.
Powered by PunBB, supported by Informer Technologies, Inc.
The pun_repository official extension is installed. Copyright © 2003–2009 PunBB.
Generated in 0.092 seconds (80% PHP - 20% DB) with 8 queries