I have a Google Drive with a folder called "Submissions". I also have a Google Apps script which both creates a 'form' as well as depositing what the end-user has uploaded (from the form) into the submissions folder.
Here is an example of the script (server.gs):
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('form.html');
}
function uploadFiles(form) {
try {
var dropbox = "Submissions";
var folder, folders = DriveApp.getFoldersByName(dropbox);
if (folders.hasNext()) {
folder = folders.next();
} else {
folder = DriveApp.createFolder(submissions);
}
var blob = form.myFile;
var file = folder.createFile(blob);
file.setDescription("Uploaded by " + form.myName);
return "File uploaded successfully " + file.getUrl();
} catch (error) {
return error.toString();
}
}
And the Form.html is as follows:
<form id="myForm">
<label>Name:</label>
<input type="text" name="myName">
<label>Email:</label>
<input type="text" name="myEmail">
<label>Demo Title (e.g "Artist - Demo Name"):</label>
<input type="text" name="myTitle">
<label>Choose Demo File:</label>
<input type="file" name="myFile">
<input type="submit" value="Submit"
onclick="google.script.run
.uploadFiles(this.parentNode);
return false;">
What this does is create a form which has "Name", "Email", "Demo Title" text fields as well as a "Submit" button. The user attaches a file and uploads the file using this form.
Now the file upload works absolutely fine. Anyone can upload a file and it will appear in a folder (Submissions) on my google drive correctly... However, the other details simply vanish as if they were never entered. I want THOSE details to appear in an existing spread sheet with preferably a timestamp.
Can anyone help me?