user1596862
user1596862

Reputation: 21

GAS : upload File using HTML service

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();
}

Upvotes: 1

Views: 1221

Answers (2)

Alejandro Silvestri
Alejandro Silvestri

Reputation: 3774

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

Upvotes: 0

Corey G
Corey G

Reputation: 7858

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

Upvotes: 1

Related Questions