How to Link Google Forms to Google Drive
Method 1: Create the Apps Script
Step 1: Open the script editor in the form
Three dots are given in the top right corner of the form. Click âMoreâ to open the dialogue box. Select âScript editorâ from the options.
Step 2: Click the untitled project on the top
Click the untitled project name at the top of the window.Rename the project to âUpload files to Driveâ.
Step 3: Create another file in the Apps Script
This step is optional, both code sections can be placed in the same script file. If you prefer separation, follow these steps:
- Click on âFileâ in the menu bar.
- Select âNewâ and then âScript fileâ.
- Name the new file âSetupâ.
Step 4: Replace the last content with the given one
Replace the content of both script files with the following content:
// Replace âForm Nameâ with the ID of your form.
var form = FormApp.openById(âYOUR_FORM_IDâ);
var folderId = âYOUR_FOLDER_IDâ; // Replace with the ID of the folder in Google Drive where you want to store the files.
// This function is triggered every time the form is submitted.
function onFormSubmit(e) {
var responses = e.response.getItemResponses();
// Loop through each form response.
for (var i = 0; i < responses.length; i++) {
var response = responses[i];
// Check if the response is a file upload question.
if (response.getItem().getType() == FormApp.ItemType.FILE_UPLOAD) {
var fileBlob = response.getResponse(); // Get the uploaded file.
var folder = DriveApp.getFolderById(folderId);
var fileName = response.getItem().getTitle(); // Use the question title as the filename.
folder.createFile(fileBlob).setName(fileName); // Save the file to Google Drive.
}
}
}
Method 2: Run The Script
Get the Form and Folder IDs. To run the script, here are the steps:-
Step 1: Replace form ID
Replace âYOUR_FORM_IDâ with the ID of your Google Form. You can find this ID in the URL of the form.
Step 2: Replace folder ID
Replace âYOUR_FOLDER_IDâ with the ID of the folder in your Google Drive where you want to store the files. If you donât have the ID, you can get it from the URL when youâre in the folder.
Step 3: Save Script
Save the script.
Step 4: Click triggers
Click on the clock icon (Triggers) in the script editor toolbar.
Step 5: Set up a trigger
Set up a trigger to run the âOn Form Submitâ function every time the form is submitted.
Upload Files to Google Drive from Google Forms
Google Forms is a free service that lets you create surveys, quizzes, and more. Google Drive is cloud storage for your files. By combining these two, you can easily collect files from respondents.
This article will guide you on uploading files to Google Drive from Google Forms. Youâll learn how to create a form with a file upload question and automatically store the uploaded files in your Drive.
How to Upload Files to Google Drive from Google Forms
- How to Create a Google Form
- How to Add the Upload File Option to the Form?
- How to Link Google Forms to Google Drive
- Importance of Uploading Files to Google Drive from Google Forms
- Conclusion
- FAQâs â Upload files to Google Drive from Google Forms