Google Apps Script: add folder to folder
<p>I used a script to upload a folder with an image to a (parent?) folder. When I do it one time is does create a folder structure the right way. But, when I try it a second time, it creates a new folder in the root with the same name. </p>

<p>How can I change my code so that there is a parent folder where image folders will be added to?</p>

<p>Currently:  </p>

<ul>
<li>First time: <code>/root/persons/test test@test.com/</code> (images inside this folder)</li>
<li>New map second time: <code>/root/persons/test2 test2@test2.com/</code> (images inside this folder)</li>
</ul>

<p>I want:<br>
  <code>/root/persons/*(folders)/</code> (images inside this folder)</p>

<p>My code:</p>

<pre><code>/* The script is deployed as a web app and renders the form */
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('form.html')
        .setSandboxMode(HtmlService.SandboxMode.NATIVE);
// This is important as file upload fail in IFRAME Sandbox mode.
}

/* This function will process the submitted form */
function uploadFiles(form) {

try {

/* Name of the Drive folder where the files should be saved */
var dropbox = form.myName + " " + form.myEmail;
var folder, folders = DriveApp.getFoldersByName(dropbox);

/* Find the folder, create if the folder does not exist */
if (folders.hasNext()) {
  folder = folders.next();
} else {
  var firstLevelFolder = DriveApp.createFolder("Persons");
  var folder = firstLevelFolder.createFolder(dropbox);
}

/* Get the file uploaded though the form as a blob */
var blob = form.myFile;    
var file = folder.createFile(blob);    

/* Set the file description as the name of the uploader */
file.setDescription("Uploaded by " + form.myName);

/* Return the download URL of the file once its on Google Drive */
return "File uploaded successfully " + file.getUrl();

} catch (error) {

/* If there's an error, show the error message */
return error.toString();
}

}
</code></pre>