воскресенье, 4 сентября 2016 г.

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.
Drive Form with File Uploads

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.
  1. <form id="myForm">
  2.  
  3. <label>Your Name</label>
  4. <input type="text" name="myName">
  5.  
  6. <label>Pick a file</label>
  7. <input type="file" name="myFile">
  8.  
  9. <input type="submit" value="Upload File"
  10. onclick="google.script.run
  11. .uploadFiles(this.parentNode);
  12. return false;">
  13. </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.
[*] 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.

0 коммент.:

Отправить комментарий