I have an HTML form that lets the user upload a file. I want to then upload that file to my google drive.
My Javascript when the user clicks submit.
var data = new FormData();
data.append('resume', document.getElementById('file'));
fetch(scriptURL, {method: 'POST', body: data })
.then(response => console.log('Success!', response))
.catch(error => console.error('Error!', error.message))
My google script
doPost(e){
uploadFile(e.parameter['file])
}
function uploadFile(file, name){
var blob = file.myFile;
var name = "file";
var contentType = "application/pdf";
var fileBlob = Utilities.newBlob(blob, contentType, name);
var file = folder.createFile(fileBlob);
}
I want the uploaded pdf to be stored in my google drive but What my current code gives me is a 9 byte pdf file that just says undefined