【问题标题】:Allow multiple files upload in SharePoint 2010允许在 SharePoint 2010 中上传多个文件
【发布时间】:2018-07-19 21:52:37
【问题描述】:

我正在尝试构建 SharePoint 自定义 Web 部件。在该 Web 部件中,我只有一个文件上传控件,我需要从一个控件上传多个文件。

我尝试了不同的代码:

<input id="files" type="file" multiple="multiple" />
<input id="files" type="file" AllowMultiple="true" />
<asp:input id="files" type="file" multiple="multiple" />

我无法从文件浏览器窗口中选择多个文件。

应用:

SharePoint:2010 版

浏览器:IE 11

请帮我解决这个问题。

谢谢你:)

【问题讨论】:

    标签: c# asp.net sharepoint sharepoint-2010


    【解决方案1】:

    从不是 Sharepoint 的开发人员,但我使用过 Devexpress 控件并且知道它们也可以在 SharePoint WebParts 中使用。试试他们的上传控件,它可以选择并上传multiple files

    【讨论】:

      【解决方案2】:

      您可以为此使用drag and drop

      function makeDroppable(element, callback) {
      
        var input = document.createElement('input');
        input.setAttribute('type', 'file');
        input.setAttribute('multiple', true);
        input.style.display = 'none';
      
        input.addEventListener('change', triggerCallback);
        element.appendChild(input);
      
        element.addEventListener('dragover', function(e) {
          e.preventDefault();
          e.stopPropagation();
          element.classList.add('dragover');
        });
      
        element.addEventListener('dragleave', function(e) {
          e.preventDefault();
          e.stopPropagation();
          element.classList.remove('dragover');
        });
      
        element.addEventListener('drop', function(e) {
          e.preventDefault();
          e.stopPropagation();
          element.classList.remove('dragover');
          triggerCallback(e);
        });
      
        element.addEventListener('click', function() {
          input.value = null;
          input.click();
        });
      
        function triggerCallback(e) {
          var files;
          if(e.dataTransfer) {
            files = e.dataTransfer.files;
          } else if(e.target) {
            files = e.target.files;
          }
          callback.call(null, files);
        }
      }
      
      var element = document.querySelector('.droppable');
      function callback(files) {
        // Here, we simply log the Array of files to the console.
        console.log(files);
      }
      makeDroppable(element, callback);
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-30
      • 2010-11-17
      • 2010-11-03
      • 1970-01-01
      • 1970-01-01
      • 2014-04-09
      • 2020-12-06
      • 2023-04-06
      相关资源
      最近更新 更多