A school teacher wants to have a public drop box (not Dropbox) where students can upload homework assignments. A recruiter wants to have an online form where job applicants can upload their resumes. A news organization may need a public drop box where people can upload files anonymously.
Google Forms would have been a perfect solution here but unfortunately you cannot upload files to Google Drive through Forms.
The other option is to have a shared folder inside Google Drive but there are limitations. One, you need a Gmail Account and should be invited by the folder owner 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 Apps Script to post the content of this form into Google Drive.
Before diving into the implementation, take a look at this sample form. When you upload a file, it will show up in a specific folder on my Google Drive. You don’t even need to have a Google Account to upload files and the Google Script based form even works on mobile devices.
- Click here to make a copy of the Google Script into your Google Drive.
- This is vanilla form with a text field, a file input field and a form submit button. You can open the form.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 the form will be uploading files to your Google Drive.
- Next choose Deploy as Web App from the Publish menu. Click Save New Version, choose Anyone, even Anonymous from the drop-down and click the Deploy button.
The Google Script will now offer you a form URL. 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>
This is a bare-bones version of the form but it can be further enhanced through Apps Script. For instance, you may choose to save the form details in a Google Spreadsheet along with the Drive URLs of the uploaded files. The script can even email you the uploaded files as attachments similar to Mail Merge.[*] 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.