Created
June 30, 2017 17:10
-
-
Save davebshow/94754ccbb5d3032e719bc21fea34e831 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://bionicteaching.com/google-script-drop-boxdisplay-package/ | |
// This script was written by Michael Price/Doug Saunders | |
function doGet(e) { | |
return HtmlService.createHtmlOutputFromFile('form.html'); | |
} | |
function uploadFiles(form) { | |
try { | |
var dropbox = "pirateboxer";//names your folder | |
var folder, folders = DriveApp.getFoldersByName(dropbox); | |
if (folders.hasNext()) { | |
folder = folders.next(); | |
} else { | |
folder = DriveApp.createFolder(dropbox); | |
folder.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.VIEW); //sets permissions on folder so anyone can view - delete this line if you want to set it manually | |
} | |
var blob = form.myFile; | |
var file = folder.createFile(blob); | |
file.setDescription("Uploaded by " + form.myName); //pulls the name field from the form | |
file.setName(form.myName + '-' + form.myDescription) //pulls the description field from the form | |
return 'File uploaded successfully - click <a href="' + folder.getUrl()+'">here to view the files</a>.'; // this links to the folder created above | |
} catch (error) { | |
return error.toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment