【发布时间】:2019-06-10 10:00:01
【问题描述】:
我正在尝试创建一种上传机制,其中我可以使用来自 HTML 的文件 ID 将文件上传到谷歌驱动器中。我不想将文件夹的 ID 放在上传功能中,因为这是需要的。我试图通过声明另一个参数即函数上传(e,id)来传递函数上传(e)的多个参数。我知道这个 onclick="google.script.run.withSuccessHandler(updateUrl).upload(this.parentNode)"
在 HTML 中触发了该函数我尝试通过 onclick="google.script.run.withSuccessHandler(updateUrl).upload(this.parentNode, '1234thisisanexampleid')" 添加另一个参数
其中 1234thisisanexampleid 是一个字符串。我也不确定 this.parentNode 是如何的。我也看到了在参数中添加逗号的结果,但我也不明白它是如何工作的。
//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>
【问题讨论】:
标签: html forms google-apps-script web-applications parameters