title: Specify folder to save files to in Google Script
body: <p>I have a simple form published through Google Apps Scripts that lets someone upload a file anonymously. The script works well, but it will always save to the root of my Google Drive instead of to a specific folder. I'd like it to create a new folder with the person's first name + last name (collected from the form) within a specific folder. I know I need to use the destination FolderID, just not sure how to use it properly.</p>
  
  <p>Here's my existing code:</p>
  
  <pre><code>function uploadFiles(form) {
  
    try {
  
  var dropbox = form.FirstName + form.LastName;
  var folder, folders = DriveApp.getFoldersByName(dropbox);
  
  if (folders.hasNext()) {
    folder = folders.next();
  } else {
    folder = DriveApp.createFolder(dropbox);
  }
  
  var blob = form.myFile;    
  var file = folder.createFile(blob);    
  file.setDescription("Uploaded by " + form.Name);
  
  return "Thank you, your file was uploaded successfully!";
  </code></pre>