How to upload multiple files using one file input element

后端 未结 3 1024
半阙折子戏
半阙折子戏 2020-12-04 15:47

I\'m trying to use one file input element to upload multiple files to Drive using html form. This seems to work only for one file, although the file picker allows selecting

3条回答
  •  时光说笑
    2020-12-04 16:24

    How about this sample script?

    In this sample, the following flow is run.

    1. Select files at browser.
    2. Upload the files every file.
    3. Save each file in Google Drive.
    4. In this sample script, the file IDs of created files are returned to the console.

    When you use this, please copy and paste the Google Apps Script and HTML to the script editor, and run the HTML using the dialog, sidebar and Web Apps.

    Code.gs: Google Apps Script

    function saveFile(obj) {
      var blob = Utilities.newBlob(Utilities.base64Decode(obj.data), obj.mimeType, obj.fileName);
      return DriveApp.createFile(blob).getId();
    }
    

    index.html: HTML and Javascript

    
    
    
    
    

    Note:

    • index.html can be run as Web Apps and the side bar and dialog of Google Docs.
    • In this sample script, the input tag uses the multiple attribute.

提交回复
热议问题