我已經下載了SWFUpload,希望能夠通過我的網站創建上傳大文件的功能。如何重置SWFUpload中的隊列?
我發現本指南:http://webdeveloperplus.com/jquery/multiple-file-upload-with-progress-bar-using-jquery/,我想我可以從此開始。不同的是,我只想只允許一次上傳一張圖片。 但我不知道如何在上傳文件後恢復SWFUpload?我希望隊列被重置並且進度條消失。
調試說:SWF DEBUG: Event: uploadError : Upload limit reached. No more files can be uploaded.
這裏是我的SWFUpload代碼:
$(function()
{
$('#swfupload-control').swfupload({
upload_url : "upload-file.php"
, file_post_name : 'uploadfile'
, file_size_limit : "102400" // 100 MB
, file_types : "*.jpg;*.png;*.gif"
, file_types_description : "Image files"
, file_upload_limit : 1
, flash_url : "js/swfupload/swfupload.swf"
, button_image_url : 'js/swfupload/wdp_buttons_upload_114x29.png'
, button_width : 114
, button_height : 29
, button_placeholder : $('#button')[0]
, debug : true
})
.bind('fileQueued', function(event, file)
{
var listitem='<li id="'+file.id+'">'+
'<span class="progresstext"><span class="progressvalue"></span> '+file.name+'</span>'+
'<div class="progressbar"><div class="progress"></div></div>'+
'</li>';
$('#log').append(listitem);
// start the upload since it's queued
$(this).swfupload('startUpload');
})
.bind('fileQueueError', function(event, file, errorCode, message)
{
alert('Size of the file '+file.name+' is greater than limit');
})
.bind('uploadStart', function(event, file)
{
$('#log li#'+file.id).find('span.progressvalue').text('0%');
})
.bind('uploadProgress', function(event, file, bytesLoaded)
{
//Show Progress
var percentage = Math.round((bytesLoaded/file.size)*100);
$('#log li#'+file.id).find('div.progress').css('width', percentage+'%');
$('#log li#'+file.id).find('span.progressvalue').text(percentage+'%');
})
.bind('uploadSuccess', function(event, file, serverData)
{
var item = $('#log li#'+file.id);
item.find('div.progress').css('width', '100%');
item.find('span.progressvalue').text('100%');
})
.bind('uploadComplete', function(event, file)
{
// upload has completed, try the next one in the queue
$(this).swfupload('startUpload');
})
});