开发者

Plupload connection between multipart=true and showing upload percentage

Seems Plupload is a great tool. But I'm stuck in a simple problem here. I have set multipart = false (I don't want to send data in chunks), however, I want to show the percentage uploaded. But it shows no % uploaded and only shows 100% at the end of upload. Here is my code.

$(function() {
        var pluploader = new plupload.Uploader({
            runtimes : 'flash', //flash,gears,flash,silverlight,browserplus,html5
            browse_button : 'img_video_upload',
            container : 'video_upload_container',
            max_file_size : '3gb',
            //chunk_size : '100kb',
            multipart : false,
            multiple_queues : false,
            multi_selection: false,
            url : 'url('*/*/videoupload')?>',
            flash_swf_url : '/public/js/plupload/js/plupload.flash.swf',
            filters : [
                {title : "Video file", extensions : "flv"}
            ]
        });

        pluploader.init();

        pluploader.bind('FilesAdded', function(up, files) {
            $('#panelWrapError').remove();
            pluploader.start(); //start file upload
        });

        pluploader.bind('UploadProgress', function(up, file) {
            $('#upload_progress').html('Progress: ' + file.name + ' ' + file.percent + '% Uploaded ' + "

"); }); pluploader.bind('FileUploaded', function(up, file, ret) { var response = eval('(' + ret.开发者_开发百科response + ')'); //hide upload progress div //$('#upload_progress').hide(); if(response.success){ $('#uploadresultwithtime').html('Your video was successfully uploaded. Please view preview.' + '

Video length: ' + response.duration + ' seconds' + '

Video size: ' + response.size + ' kb' ); } if(response.error){ $('#uploadresultwithtime').html(response.message); } }); pluploader.bind('Error', function(up, err) { $('#panelWrap').prepend('

  • ' + err.message +'
'); }); });


You have only set "flash" as your runtime. Plupload doesn't have any way of knowing upload progress when using the flash runtime and not using chunked uploads.

You either have to accept no progress indication using flash and activate other runtimes (html5, gears etc.) where it will work, or activate chunked uploads that makes flash able to tell how many chunks of the total amount of chunks it has uploaded.

That means that if you have a 1mb file to upload and the chunk_size is set to 100kb, then flash will be able to show 10,20,30 - 100 % (a step at each chunk.)

Try to set the following in plupload options for optimal support.

runtimes : "gears,flash,silverlight,browserplus,html5", chunk_size : '100kb'

Remember that your server needs to support receiving chunked uploads.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜