有没有方法以编程方式将AppsUploadItem添加到Google Apps中的Google表单? 我找不到一个函数:以编程方式在Google Apps脚本中将FileUploadItem添加到Google表单
Form.addFileUploadItem() or Item.asFileUploadItem().
有没有方法以编程方式将AppsUploadItem添加到Google Apps中的Google表单? 我找不到一个函数:以编程方式在Google Apps脚本中将FileUploadItem添加到Google表单
Form.addFileUploadItem() or Item.asFileUploadItem().
有你试过了这个例子:https://ctrlq.org/code/19747-google-forms-upload-files或这一个http://www.googleappsscript.org/user-interface/upload-doc
<!-- Paste this into forms.html -->
<!-- Text input fields -->
<input id="name" type="text" placeholder="Your Name">
<input id="email" type="email" placeholder="Your Email">
<!-- File upload button -->
<input id="file" type="file">
<!-- Form submit button -->
<button onclick="submit(); return false;">Submit</button>
<!-- Show Progress -->
<div id="progress"></div>
<!-- Add the jQuery library -->
<script src="https://code.jquery.com/jquery.min.js"></script>
<script>
var file,
reader = new FileReader();
// Upload the file to Google Drive
reader.onloadend = function(e) {
google.script.run
.withSuccessHandler(showMessage)
.uploadFileToGoogleDrive(
e.target.result, file.name,
$('input#name').val(),
$('input#email').val()
);
};
// Read the file on form submit
function submitForm() {
file = $('#file')[0].files[0];
showMessage("Uploading file..");
reader.readAsDataURL(file);
}
function showMessage(e) {
$('#progress').html(e);
}
</script>
感谢您的回答。我尝试通过Form.addFileUploadItem()向Google Forms添加一个UploadItem。 Afaik,在Google表单中不能使用HTML。 – net3k
创建功能要求在这里:https://issuetracker.google.com/issues/62981173
证实似乎没有好的办法解决此问题,因为我无法找到创建通用表单响应而没有遵循Item.asTypeItem()模式。
我有一个批准工作流,我从文件上传字段获取数据并将其推送到另一个表单中的纯文本字段,但这并不理想。
// you can access the file selected from a
// form as an array of file IDs
var fileIDArray = itemResp.getResponse()
// If you want URLs to present to a user, that's a snap too...
var urlArray = fileIDArray.map(
\t function (id) {
\t \t return DriveApp.getFileById(id).getUrl()
\t })
// But alas, there is no way to push a new response
// successfully.
我无法找到一个文件上传任何项目正在创建通过Google Apps脚本或者通过先进的驱动器API。 – Brian