有沒有方法以編程方式將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