Steps to create a registration form that allow a user to upload a file to my company's shared google drive folder. The user does not belong to my domain therefor do not have access to the shred drive folder. When the user submit the form I want to record the information on a google sheet
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
This is a common challenge, as Google Forms' native file upload feature requires users to be logged into a Google account and often to be part of the same domain or have specific sharing permissions configured beforehand. Since your users are external, we need a workaround.
The most robust and integrated solution involves using Google Forms for the registration data, having the user upload their file to their own Google Drive, sharing a link, and then using Google Apps Script to automatically copy that file into your company's shared Google Drive folder when the form is submitted.
Here's a step-by-step guide:
The Strategy
User uploads to their Google Drive: The user will upload their file to their own Google Drive account.
User provides a Shareable Link: They will then generate a shareable link (with "Anyone with the link can view" access) and paste it into a specific field on your Google Form.
Google Form for Registration Data: Collects all registration details and the file link.
Google Sheet for Data Storage: The form automatically populates a Google Sheet with all submitted data.
Google Apps Script for File Copying: An Apps Script attached to the Google Form will automatically trigger on form submission. It will read the provided link, access the file (because the user made it viewable), and make a copy of it into your designated company Google Drive folder. This new copy will be owned by your company/the script owner.
Step-by-Step Implementation
Part 1: Set up your Company's Shared Google Drive Folder
Create or Identify your Destination Folder: In your company's Google Drive (or a shared drive), create a new folder (e.g., "Registration Submissions" or "Uploaded Files").
Get the Folder ID:
Navigate to this new folder in your Google Drive.
Look at the URL in your browser. The Folder ID is the long string of characters after /folders/.
Example URL: https://drive.google.com/drive/folders/1aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456
Folder ID: 1aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456
Copy this ID. You'll need it for the Apps Script.
Part 2: Create your Google Form and Link to a Google Sheet
Create a New Google Form: Go to forms.new or drive.google.com > New > Google Forms.
Add Registration Fields: Add all the standard fields you need (Name, Email, Phone, Company, etc.).
Add the "File Upload Link" Field (Crucial!):
Add a new question.
Question Title: Something like "Link to Your Uploaded File" or "Resume/Portfolio Link".
Question Type: Select Short answer or Paragraph.
Add Description (VERY IMPORTANT!): Provide clear instructions for the user:
code
Please upload your file (e.g., Resume, Portfolio PDF) to your own Google Drive, Dropbox, or any cloud storage service.
Then, generate a shareable link for that file and paste it here.
If using Google Drive, please ensure the sharing setting is set to "Anyone with the link can view" so we can access it.
How to get a Google Drive link:
1. Upload your file to drive.google.com.
2. Right-click the file and select "Get link".
3. In the sharing dialog, change the access to "Anyone with the link" and set permission to "Viewer".
4. Copy the link and paste it above.
Make this field Required.
Link to a Google Sheet:
In your Google Form, click on the "Responses" tab.
Click the green Google Sheets icon.
Choose "Create a new spreadsheet" or "Select existing spreadsheet". This sheet will automatically record all form submissions.
Part 3: Set up Google Apps Script to Copy the File
Open Script Editor:
From your Google Form, click the three vertical dots (More) menu in the top right.
Select Script editor. A new tab will open with the Google Apps Script project.
Paste the Code:
Delete any existing code in Code.gs.
Paste the following Google Apps Script code into the editor.
REMEMBER TO REPLACE YOUR_COMPANY_DRIVE_FOLDER_ID_HERE with the actual Folder ID you copied in Part 1.
Also, adjust FILE_LINK_QUESTION_TITLE to exactly match the title of your "File Upload Link" question in the form.
javascript
Part 4: Testing Your Setup
Open your Google Form in a new Incognito/Private window (to simulate an external user who isn't logged into your domain).
Prepare a test file:
Upload a dummy file (e.g., a simple PDF or text file) to your personal Google Drive account.
Right-click the file, select Get link.
Crucially: Change the sharing setting to Anyone with the link and Viewer. Copy this link.
Fill out your Google Form:
Enter dummy registration data.
Paste the shareable link of your test file into the "Link to Your Uploaded File" field.
Submit the form.
Check the Google Sheet:
Open the Google Sheet linked to your form. You should see a new row with your submitted data.
Look at the last column (or the "File Copy Status" column if you created it). It should show "File copied successfully..."
Check your Company's Shared Google Drive Folder:
Navigate to the destination folder you created in Part 1.
You should see a copy of your test file there, named according to your script's naming convention (e.g., UserName_UserEmail_OriginalFileName_timestamp).
Important Considerations:
User Instructions are KEY: The success of this solution heavily relies on your users following the instructions to upload their file to their own cloud storage and providing a shareable link with "Anyone with the link can view" access. Make these instructions on your form as clear as possible, maybe even with screenshots or a short video tutorial.
Error Handling: The provided script has basic error handling. If a link is invalid, not accessible, or not a Google Drive link, the script will log an error in the "File Copy Status" column of your sheet. This is crucial for troubleshooting.
File Ownership: When the script copies the file, the copy in your company's Drive folder becomes owned by the script owner (you or the account that ran the script). The original file remains owned by the external user.
Security: Ensure the DESTINATION_FOLDER_ID is correct. The script only copies files; it doesn't give external users access to your folder.
Alternative File Storage: While the script is optimized for Google Drive links, users could theoretically upload to other services like Dropbox or OneDrive and provide a public link. However, DriveApp.getFileById() specifically works with Google Drive files. If you need to support other services, the script would become significantly more complex (e.g., using UrlFetchApp to download the file and then DriveApp.createFile()). For simplicity and integration, stick to instructing users to use Google Drive if possible.
File Naming Convention: The script creates a unique file name for the copied file to avoid conflicts and add context. You can customize the newFileName variable in the script to include other form data (e.g., companyName, registrationDate).
This setup provides a robust and free way to manage external file uploads directly into your Google Drive, integrated with your registration data in a Google Sheet.
const DESTINATION_FOLDER_ID = 'YOUR_COMPANY_DRIVE_FOLDER_ID_HERE'; // <-- REPLACE THIS!
const FILE_LINK_QUESTION_TITLE = 'Link to Your Uploaded File'; // <-- REPLACE THIS to match your form question title
function onFormSubmit(e) {
const formResponse = e.namedValues;
const fileLink = formResponse[FILE_LINK_QUESTION_TITLE] ? formResponse[FILE_LINK_QUESTION_TITLE][0] : null; // Get the file link from the form response
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getActiveSheet();
const lastRow = sheet.getLastRow();
let fileCopyStatus = "No link provided."; // Default status
if (fileLink) {
try {
// Extract file ID from various Google Drive link formats
let fileIdMatch = fileLink.match(/\/d\/([a-zA-Z0-9_-]+)/); // For standard view/edit links
if (!fileIdMatch) {
fileIdMatch = fileLink.match(/id=([a-zA-Z0-9_-]+)/); // For older links
}
if (!fileIdMatch) {
fileIdMatch = fileLink.match(/file\/d\/([a-zA-Z0-9_-]+)/); // For some preview links
}
let fileId = fileIdMatch ? fileIdMatch[1] : null;
if (fileId) {
const sourceFile = DriveApp.getFileById(fileId);
const destinationFolder = DriveApp.getFolderById(DESTINATION_FOLDER_ID);
// Generate a unique name for the copied file to avoid overwrites and include user context
// You can customize this to include name, email, etc. from formResponse
const userName = formResponse['Name'] ? formResponse['Name'][0] : 'UnknownUser'; // Assuming you have a 'Name' field
const userEmail = formResponse['Email'] ? formResponse['Email'][0] : 'UnknownEmail'; // Assuming you have an 'Email' field
const originalFileName = sourceFile.getName();
const newFileName = `${userName}_${userEmail}_${originalFileName}_${Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "yyyyMMdd_HHmm")}`;
const copiedFile = sourceFile.makeCopy(newFileName, destinationFolder);
fileCopyStatus = `File copied successfully: ${copiedFile.getName()} (ID: ${copiedFile.getId()})`;
Logger.log(fileCopyStatus); // For debugging
} else {
fileCopyStatus = "Error: Could not extract valid Google Drive File ID from link.";
Logger.log(fileCopyStatus + " Link: " + fileLink);
}
} catch (e) {
fileCopyStatus = `Error copying file: ${e.message}. Please check link permissions. Link: ${fileLink}`;
Logger.log(fileCopyStatus); // For debugging
}
}
// Add a column to the Google Sheet to record the file copy status
// This assumes the script is attached to the form, which automatically logs responses.
// We need to add this status to the *last* column of the submitted row.
// To ensure a consistent column for the status, you might want to add a column header "File Copy Status" manually
// in your linked Google Sheet first, beyond the last form question column.
// Find the "File Copy Status" column dynamically
const headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
let statusColumnIndex = headers.indexOf('File Copy Status');
// If the column doesn't exist, append it
if (statusColumnIndex === -1) {
sheet.appendColumn('File Copy Status');
statusColumnIndex = sheet.getLastColumn() - 1; // 0-indexed
}
// Write the status to the correct cell in the last submitted row
sheet.getRange(lastRow, statusColumnIndex + 1).setValue(fileCopyStatus); // +1 because getRange is 1-indexed
}
Save the Script: Click the floppy disk icon (Save project) or File > Save. You might be prompted to name the project (e.g., "Registration File Uploader").
Set up the Trigger: This tells the script when to run.
In the Apps Script editor, click the clock icon on the left sidebar (Triggers).
Click + Add Trigger in the bottom right.
Configure the trigger:
Choose which function to run:onFormSubmit
Choose which deployment should run:Head (default)
Select event source:From form
Select event type:On form submit
Failure notification settings:Notify me immediately (recommended for testing)
Click Save.
Authorize the Script:
The first time you save the trigger, Google will ask you to authorize the script.
Click Review permissions.
Select your Google account.
You'll see a warning that "This app isn't verified by Google" (this is normal for your own scripts). Click Advanced then Go to [Project Name] (unsafe).
Click Allow to grant the script permission to access your Google Drive and Google Sheets.