1
votes

I am in the process of building my first application that makes use of Google Apps Script & HTMLService. I need to have a form that allows the upload of a file to a Google Documents List. This is my current code and it doesn't work .

index.html : This page contains a simple form (action="<=? action ?>") with a input file (name & id equal myFile) and submit button

code.gs :

function doGet(e) {
var template = HtmlService.createTemplateFromFile(index.html');
template.action = ScriptApp.getService().getUrl();
return template.evaluate();
}


function doPost(e) {
var template = HtmlService.createTemplateFromFile('Thanks.html');
var f = DocsList.createFile(e.parameter.myFile);
return template.evaluate();
}
2
Please be more specific than "it doesn't work" and explain what is happening. - Corey G
the function DocsList.createFile(e.parameter.myFile) return this error : Cannot find method createFile(string). how can I do to upload file with HTMLService plz - user1596862

2 Answers

1
votes

Files do not show up to doPost this way. Let me think about whether there's a good workaround.

0
votes

I just read in documentation DocList.createFile(blob) is only avaliable for Google Apps accounts:

method createFile(blobSource)

Creates a file with the given name and content in the DocsList. This method is only available for Google Apps accounts.

https://developers.google.com/apps-script/class_docslist?hl=es-ES#createFile