2
votes

I have a basic Google app script that uses html form to capture a few input fields and then allow the user to select a file to upload to my drive. This has been published on the web. I want this for any user (even without google accounts). I have used the annynous settings for the script and the folder but still it asks people to login to Google before providing access. Can you help? most appreciated.

function doGet(e) {
  return HtmlService.createHtmlOutputFromFile('form.html');
}

function uploadFiles(form) {

  try {

    var timestamp = new Date();
    var dropbox = "yourFolder";
    var folder, folders = DriveApp.getFoldersByName(dropbox);

    if (folders.hasNext()) {
      folder = folders.next();
    } else {
      folder = DriveApp.createFolder(dropbox);
    }

    var blob = form.myFile;  
    blob.setName(form.myName + timestamp);
    var file = folder.createFile(blob);  
    file.setDescription("Uploaded by " + form.myName);

   var SPREADSHEET_ID = "spreadsheet url here";

   var ss = SpreadsheetApp.openByUrl(SPREADSHEET_ID);
   var sheet = ss.getSheets()[0];
   sheet.appendRow([timestamp, form.myTitle, form.myName, form.myEmail, form.mySchool,  form.myCat]);

    return "File uploaded successfully " + " by " + form.myName + ": " + file.getName(); Url();

  } catch (error) {

    return error.toString();
  }


}
1

1 Answers

0
votes

When you deploy the web app, it must also run as:

Execute the app as:

me(your email address)

Also, make sure that after you make any changes, that you save a new version, and deploy that version. Otherwise, the old settings will still be in affect.