English 中文(简体)
插头载荷
原标题:plupload removeFiles

我试图删除档案,不允许在卷宗Added活动上延期。 (由于我需要一个排他性清单,我可以使用过滤参数。)

我有这样的一些法典:

uploader.bind( FilesAdded , function(up, files) {
    var count = files.length;
    var i = 0;
    for (i;i<count;i++) {
        var validExt = validate(files[i].name);
        if(!validExt){

如果延期无效,我需要删除这些档案。 我尝试如下:

uploader.splice(i,1)
uploader.removeFile(files[i]);
uploader.refresh();

The FilesRemoved event is fired, but removed files still get uploaded with uploader.start().

我不知道这是否是该方案的丑恶,或过于模糊,无法期望一个容易的答案,但如果任何人能够帮助,我真的感激。 页: 1 我没有任何明显的东西。

感谢。

最佳回答

几个方面......

页: 1 在要求启动(a)功能后添加活动。

uploader.init();

uploader.bind( FilesAdded , function (up, files) {...}

第2条 在确定电压时,可使用推进器过滤器过滤文档。

uploader = new plupload.Uploader({
        ...,
        filters: [
            { title: "Image files", extensions: "jpeg,jpg,gif,png" }
        ],
        ...
    });

3rd here s a working sample to remove files from plupload

$.each(uploader.files, function (i, file) {
    if (file && file.id != currentFile.id) {
        uploader.removeFile(file);
    }
});

Cheers!

问题回答

When there is no upload progress and you want to remove all queued files from uploader list:

var queueLength = 上载者.files.length;

for (i = 0; i < queueLength; i++) {

如果(上载人.files[0] &&上载人.files[0]!=未界定){

卸载者:

iii

iii

注:如果你试图按索引删除档案,则有些档案留在名单上;因为每当档案项目从名单上删除时,都会更新,索引使用。

你需要通过你想要去除的那份档案。 文件:

<编码>uploader.removeFile(files [i].id]

你们也可以使用“QueueChanged”电话,为我工作。

uploader.bind( QueueChanged , function(up){

  var file_count = up.files.length;
  for(i = 0; i < file_count; i++) {
    if(i != (file_count - 1)) up.removeFile(up.files[i]);
  }

});
uploader.bind( FilesAdded , function(up, files) {
    if( files.length > 1 )
    {
        $.each(files, function(i, file) {
            up.removeFile(file);    
        });
    }
});




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签