Accessing object is Google App Script

2019-06-03 10:18发布

问题:

I am actually following the HtmlService documentation (https://developers.google.com/apps-script/html_service) in creating a form. I notice there is this part where it says it will be an object after user submit the form and the structure will be like this:

{ myFile: <a Blob containing the file>; aField: <the value in the field> }

Can I know how can I access to those object in Google App Script?

回答1:

In your server code:

function processForm(theForm) {
  Logger.log(theForm.aField);
  Logger.log(theForm.myFile.getName());
}

In your HTML:

<form id='myForm'>
<input name='myFile' type='file'>
<input name='aField'>
</form>
<script>
google.script.run.processForm(document.getElementById('myForm'));
</script>