0

I have created a basic file upload form with google script. Im wondering if someone can help me add a progress bar or some sort upload percentage indiation so that users dont navigate from the form before upload is complete.

Here is the Google script: Code.gs

function doGet() {
  var html = HtmlService.createHtmlOutputFromFile('index');
  return html;
}


function uploadFiles(data)
{
 var file = data.myFile;
 var folder = DriveApp.getFolderById('XXXXXXXXXXXXXXXXXXXXXXXX');
 var createFile = folder.createFile(file);
 
}

Here is the form code: index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <title>Upload Files</title>
  </head>
  <body>
    <h1>File Uploader</h1>
    <form>
        <input type="file" name="myFile" multiple>
        <br>
        <br>
        <input type="button" id="submitBtn" value="Upload Files">
        <label id="resp"></label>
    </form>
    <script>
      document.getElementById('submitBtn').addEventListener('click',
        function(e){
          google.script.run.withSuccessHandler(onSuccess).uploadFiles(this.parentNode)
        })
        
        function onSuccess(data){
          document.getElementById('resp').innerHTML = "File Uploaded Successfully!";
        }
       
    </script>
  </body>
</html>
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • Welcome to Stack Overflow. What have you already tried yourself? Please review [How do I ask a good question](https://stackoverflow.com/help/how-to-ask) to see what you need to give us. We are here to help you solve problems, not write code for you. Do some research, make a good attempt at doing this yourself and then if you still have problems, you can update your question with details of the specific problem, what you have tried, and your relevant code in a [minimal,reproducible example](https://stackoverflow.com/help/minimal-reproducible-example), so we are able to help. – FluffyKitten Jul 11 '20 at 01:24
  • I think that in your case, the process cost of Google side is much higher than that of Javascript. So I thought that it might be suitable for your situation, when some text is display under the processes of both Javascript and Google Apps Script. How about this? By the way, you are using V8 runtime? Because I thought that when V8 runtime is used, your script cannot upload the file by the error. [Ref](https://stackoverflow.com/q/60742695/7108653) – Tanaike Jul 11 '20 at 02:30

0 Answers0