Google Apps Script Google Drive How to ?

Create Form to Upload Files in Google Drive

Today Google form is the most widely used web form service used for many purposes. Some of its attractive features include intuitive drag and drop interface, quick integration with Google Sheets and not to mention add-ons which even enhance its capability. Despite all these features, it misses an important one that is uploading files or in other words, keeping file inputs to receive PDF or any other documents from form submitters. This has been a widely discussed topic even in forums.

Password Manager Demo

Now in this post we will introduce you to a script which can help in uploading file with Google Form like interface. Google form uses materialize design pattern (tech geeks). We have created this HTML form using materialize css which looks exactly similar like Google Form. In addition to that it can upload files as well. It stores the submitted data in Google Spreadsheet and files in the specified folder.

Features

  • Uploads file in the form which looks similar as Google Form
  • Stores submitted data in the Google Spreadsheet
  • Saves file in the specified folder
  • Stores the links of the files in the Spreadsheet
  • Multiple files can also be uploaded

Set up

  • Go to file → Make a copy
  • A new tab will be opened → Rename the file
  • Close the original file
  • In the new file → go to Tools → Script editor
  • In the script you will find some constant variable at the top. You need to replace with your own values.
  • Go to publish → Deploy as webapp
    • Project version: new
    • Execute the app as: me
    • Who has access to the app: Anyone even anonymous 
  • Update → You will get an URL for the form

7 thoughts on “Create Form to Upload Files in Google Drive”

  1. Hi Hari!
    thank you for the great script
    please I need your help!
    how can we add our questions in the form?
    can I add a lat-long map picker with google maps and if it possible how?
    and as you know we can not add the form on anny website if the opption of uplaoad file is added
    Best regards

    1. To add new questions, you have to edit the html. But you have to strictly follow the same format (class names etc.) like other questions. Yeah, you can put lat-long picker or any other inputs but you have to store the final value in a hidden input.

      I did not understand the last question ? Why we cannot add to website if file upload form is added ?

  2. Hi Hari,

    Thank you for posting this info. It is very useful. One question: In code.gs, there is a function call sendNotificationEmail to send email (currently commented out) but there is no function that is supposed to trigger the email.

    Can you tell me how to enable email notification?

    Regards,
    Sunish

    1. You just need to deploy the app as web app. It will automatically send email notification when the form is submitted.

  3. Hi this was very useful fo me. Thank you so much.
    Yet, I am having hard time embedding the script with , as (I guess) the sandboxMode prevents the XFrameOptions. Can you help here?
    Thanks again.

Leave a Reply

Your email address will not be published. Required fields are marked *