Plupload - Restrict to only one file

后端 未结 13 1019
攒了一身酷
攒了一身酷 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 11:01

    After trying each of the solutions, I came up with the simplest of all -- which seems to work.

    I'm using the core api and I have multi_selection set to false. Then, after the first file is selected (added) the second line of code, which I inserted into the FilesAdded event, hides the browse link. I don't think this can be done with the jquery widgets and I also have found that unless the upload link covers where the browse link is, it remains alive.

    uploader.bind('FilesAdded', function(up, files) {
    //line below hides button
    document.getElementById("browse").style.display = "none";
    
    var html = '';
    plupload.each(files, function(file) {
    html += '
  • ' + file.name + ' (' + plupload.formatSize(file.size) + ')
  • '; }); document.getElementById('filelist').innerHTML += html;

    });

提交回复
热议问题