Upload Files to Google Drive with Google Apps Script

Google Forms do not offer the file uploads feature but you can use Google Apps Script and let anyone upload files to Google Drive through an HTML web form.

For instance, you can share the form with your class, or with your clients, and they can directly upload school assignments, photographs, and other documents to a specific folder in your Google Drive.

There are two steps involved here. First you need to create an HTML form using HTML and CSS.

Here’s a sample form that uses the Materialize CSS library to give the standard Google Forms like material look to your file upload form.


The server side Google Script code includes a function for processing the form input. It reads the uploaded file as a blob and saves the blob as a new file into your Google Drive. The file name, extension, and content type are preserved.

[*] The premium version of the file upload form (demo form) lets you visually create forms and allow file uploads of any size via the Google File Picker API.

/* The script is deployed as a web app and renders the form */
function doGet(e) {
  return HtmlService
    .setTitle("Google File Upload by");

function uploadFileToGoogleDrive(data, file, name, email) {

  try {

    var dropbox = "My Dropbox";
    var folder, folders = DriveApp.getFoldersByName(dropbox);

    if (folders.hasNext()) {
      folder =;
    } else {
      folder = DriveApp.createFolder(dropbox);

    var contentType = data.substring(5,data.indexOf(';')),
        bytes = Utilities.base64Decode(data.substr(data.indexOf('base64,')+7)),
        blob = Utilities.newBlob(bytes, contentType, file);

    folder.createFolder([name, email].join(" ")).createFile(blob);

    return "OK";

  } catch (f) {
    return f.toString();


You can save the two files and deploy the Google script as a web app with access to anyone, including anonymous as shown in this GIF.