-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppScriptCode.gs
31 lines (26 loc) · 912 Bytes
/
AppScriptCode.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var folderID = "1Ft_a8gdKQYbjpwux6iZugRkVj7rXKPt_"; //Replace the "root"with folder ID to upload files to a specific folder
function doGet() {
return HtmlService.createTemplateFromFile('form').evaluate();
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
function uploadFiles(formObject) {
try {
var folder = DriveApp.getFolderById(folderID);
// Check if file exists in formObject and is not null
if (formObject.myFile && formObject.myFile.length > 0) {
var blob = formObject.myFile;
var file = folder.createFile(blob);
file.setDescription("Uploaded by " + formObject.first_name);
fileUrl = file.getUrl();
fileName = file.getName();
} else {
fileUrl = "Record saved without a file";
}
return fileUrl; // Return the file URL
} catch (error) {
return error.toString();
}
}