【发布时间】:2014-10-05 02:40:27
【问题描述】:
我想创建一个包含图像上传字段的数据收集表单。我试过谷歌表单,它本身不支持文件上传,但我发现了这个例子:Form and file upload with htmlService and app script not working
我设法通过图片上传对其进行了配置,但是,原生 Google 表单在电子表格响应中确实有一个时间戳列。
我试过了:
var timestamp = theForm.getTimestamp();
但是没用……
如何获取响应时间戳?
代码摘录:
function processForm(theForm) {
var fileBlob = theForm.myFile;
var folder = DriveApp.getFolderById(folderId);
var doc = folder.createFile(fileBlob);
// Fill in response template
var template = HtmlService.createTemplateFromFile('Thanks.html');
var name = template.name = theForm.name;
var email = template.email = theForm.email;
var timestamp = template.timestamp = theForm.getTimestamp();
// Record submission in spreadsheet
var sheet = SpreadsheetApp.openById(submissionSSKey).getSheets()[0];
var lastRow = sheet.getLastRow();
var targetRange = sheet.getRange(lastRow+1, 1, 1, 5).setValues([[timestamp,name,department,message,email,fileUrl]]);
// Return HTML text for display in page.
return template.evaluate().getContent();
}
【问题讨论】: