I am trying to upload the file "pdf " to google drive through google app script, but I get an error when I click the button. Also, I wanted to use the array bytes but I don't know how to do because without the array bytes I must disable the chrome v8.
Error message :
2495449455-mae_html_user_bin_i18n_mae_html_user__ar.js:56 Uncaught InvalidArgumentError: Failed due to illegal value in property: 0
<!DOCTYPE html>
<html lang="en">
<head>
<base target="_self">
<?!=include('css');?>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title> PDF Collector</title>
<div align="center">
<p><img class="responsive-img offset-m3 s12 "
src=""></p>
</div>
</head>
<body>
<div id="msg" class="col m6 offset-m3 s12" align="center" style='color: red' >
<div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col m6 offset-m3 s12 ">
<div class="input-field">
<input placeholder="Your Id" id="employeeId" type="number" class="validate" required pattern ="^\d{10}$" >
<label class="active" for="id">Your Id</label>
</div>
<div class="input-field">
<input placeholder="Your name" id="fullname" type="text" class="validate" disabled >
<label class="active" for="name">Full Name</label>
</div>
<div class="file-field input-field">
<div class="btn">
<span>File</span>
<input type="file" name="myFile">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
</div>
</div>
<button id="btn" class="btn waves-effect waves-light" type="submit"
name="action" > Submit
<i class="material-icons right">send</i>
</button>
</div>
</div>
<div class="row">
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<?!=include('js');?>
</body>
</html>
JS Code
document.getElementById('btn').addEventListener('click',
function(e){
google.script.run.withSuccessHandler(onSuccess).uploadFiles(this.parentNode)
})
function onSuccess(data){
document.getElementById('msg').innerHTML = "Thanks for Uploading";
}
This the function in .gs
function uploadFiles(data)
{
var file = data.myFile;
var folder = DriveApp.getFoldersByName(collected-Pdf);
Logger.log(folder);
var createFile = folder.createFile(file);
}