Can't pass multiple parameters in an onclick function

Viewed 453

I am trying to create an upload mechanism wherein I can upload a file in google drive by using it's file ID from HTML. I don't want to place the ID of the folder inside the upload function as this is needed. I am trying to pass multiple arguments on function upload(e) by declaring another parameter i.e. function upload(e,id). I am aware that the function is trigged in the HTML by this onclick="google.script.run.withSuccessHandler(updateUrl).upload(this.parentNode)"

I tried to add another parameter by onclick="google.script.run.withSuccessHandler(updateUrl).upload(this.parentNode, '1234thisisanexampleid')"

Where 1234thisisanexampleid is a string. I am also not sure how the this.parentNode as well. I have also seen results of adding commas in parameters but I also don't understand how it works.

 //code gs    
 function doGet() {
  return HtmlService.createHtmlOutputFromFile('Form.html');
}

function upload(e) { 



 // Folder ID of destination folder
 var destination_id = xxx;



var img = e.imageFile;

var destination = DriveApp.getFolderById(destination_id);

destination.createFile(img);

return "File Uploaded Successfully!";
}



//Form.html (just a part of the code)
<form>
  <input type="file" name="imageFile">
  <input type="button" value="Upload File" onclick="google.script.run.withSuccessHandler().upload(this.parentNode)">
</form>
1 Answers
Related