How to Receive Files in your Google Drive from Anyone
A school teacher wants to have a public drop box (not Dropbox) where students can upload homework assignments. A designer may need a public drop box where clients can upload photographs easily. A recruiter wants to have an online form where job applicants can upload their resumes.
Google Forms would have been a perfect solution here but unfortunately you cannot upload files to Google Forms.
The other option is to have a shared folder inside Google Drive where others may upload files but this approach does have limitations. One, only people with a Google account would be able to upload files in a shared folder. Second, all collaborators can view and even remove files that have been uploaded in a shared folder on Google Drive.
Receive Files in Google Drive with Forms
What you can do is create a regular web form (written in HTML and CSS) and then use Google Scripts to upload the content of this form into a folder in your Google Drive.
Before diving into the implementation, take a look at this sample form. When you submit the form, it will create a new folder, corresponding to your name, in my Google Drive and upload the file in that folder This is a public form and you don’t even need to have a Google Account to upload files. The form also works on mobile devices.
- Click here to make a copy of the Google Script into your Google Drive.
- This is vanilla form with a few text fields and a file upload button. You can edit the forms.html file to apply your own CSS styles or add more input and textarea fields.
- From the Run menu, choose doGet and authorize the script. The script needs these permissions since users will be uploading files to your Google Drive.
- Next choose Deploy as Web App from the Publish menu, choose Anyone, even Anonymous under who has access and then click the Deploy button.
The Google Script will now offer you the link (URL) of your form. Anyone can now use this form to upload files to your Google Drive.
<form id="myForm"> <label>Your Name</label> <input type="text" name="myName"> <label>Pick a file</label> <input type="file" name="myFile"> <input type="submit" value="Upload File" onclick="google.script.run .uploadFiles(this.parentNode); return false;"> </form>
The advanced version of the file upload form is even more capable.
It can save the form responses in a Google Spreadsheet along with the Drive URLs of the uploaded files. Form users can upload files of any size and you can get email notifications when people submit your form.
PS:If this looks a bit too technical, you can ask guests to send you files as email attachments and then use the Gmail to Google Drive program to automatically save these file attachments in your Drive.
[**] If you aren’t on Gmail or Google Apps, you can still receive files in Dropbox from anyone anonymously.
Google Developer Expert, Google Cloud Champion
Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.
Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory