使用Google表单上传文件时如何获取文件名 [英] How to get filename when using google forms to upload a file

查看:140
本文介绍了使用Google表单上传文件时如何获取文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google表单,我的用户用来上传文件. 我记录以下内容

I have a google form which my users use to upload files. I record the following

  1. 唯一ID(由用户输入)
  2. 文档的类别(用户通过表格中的下拉菜单选择)
  3. 文件本身(由用户上传)
  4. 记录在电子表格中的Google驱动器链接.

我找不到一种方法来获取上载文件的实际文件名.

I am unable to find a way to get the actual filename, of the uploaded file.

我的要求

  1. 使用电子表格中的自定义功能,使用上述驱动器链接提取文件名(如上4)

  1. 我可以通过Google表单本身记录上传文件的文件名的任何规定.

我们非常感谢您的帮助.

Any help is highly appreciated.

推荐答案

您可以使用由Google表格的OnFormSubmitOnChange触发的Apps脚本.

You can use Apps script triggered by OnFormSubmit or OnChange of the Google Sheets.

以下是一些相关的文章: -如何获取onFormSubmit自动触发? -如何在Submit事件处理程序中获取表单值?

Here are some related post: - How to get onFormSubmit to trigger automatically? - How to get form values in the submit event handler?

OR

使用Apps Script Web App托管表单,然后在Apps Script中控制所有提交的详细信息.

Use an Apps Script Web App to host your form then control all the submitted details in Apps Script.

以下是一些教程:

  • Upload Files to Google Drive with Google Apps Script
  • How to Create Forms that allow File Uploads to Google Drive
  • Google Forms file upload complete example

根据我的测试(OnFormSubmit()OnChange()),这可能很复杂,因为OnFormSubmit()将仅获取提交项目的fileID.您必须执行另一个查询才能获取上载文件的名称,然后将其保存到表格中.在使用Web App时,您将能够在上载文件之前获取文件名,从而实现此请求所需的请求更少.

Based from my test (OnFormSubmit() and OnChange()), this can be complex as OnFormSubmit() will only get the fileID of the submitted item. You have to do another query to get the name of the uploaded file then save it to your Sheets. While in the Web App, you will be able to get the file name before uploading it thus lesser request needed for this implementation.

希望这会有所帮助.

这篇关于使用Google表单上传文件时如何获取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆