Plupload - Restrict to only one file

后端 未结 13 1216
攒了一身酷
攒了一身酷 2021-02-02 10:15

I don\'t see an option in the plupload API docs on restricting the number of files uploaded, to any number, even 1.

Doc fail? or Feature fail? If it doesn\'t exist I\'ll

13条回答
  •  时光说笑
    2021-02-02 10:58

    I realize this has been answered, but a solution I went with was to just use the QueueChanged callback:

    QueueChanged: function(uploader) {
        // Called when queue is changed by adding or removing files
        //log('[QueueChanged]');
        if(uploader.files.length > 1) {
            uploader.files.splice(0, (parseInt(uploader.files.length) - 1));
        }
    }
    

    With this code, it only keeps the last selected file (in case the reason they chose again was because they chose the wrong file).

提交回复
热议问题