my code is able to uplolad to the google sheet but not the files anyone assist wth modification to upload files and shhet update same time
<form method="post" name="google-sheet">
<div class="form first">
<div class="details personal">
<span class="title">Personal Details</span>
<div class="fields">
<div class="input-field">
<label for="fname">First Name</label>
<input name="First-Name" type="text" placeholder="Enter your first name" required>
</div>
<div class="input-field">
<label for="fname">Last Name</label>
<input name="Last-Name" type="text" placeholder="Enter your last name" required>
</div>
<div class="input-field">
<label for="fname">Email</label>
<input name="Email" type="email" placeholder="Enter your email" required>
</div>
<div class="input-field">
<label for="fname">Mobile Number</label>
<input name="Number" type="tel" placeholder="Enter mobile number" required>
</div>
<div class="input-field">
<label for="fname">Gender</label>
<select name="Gender" required>
<option disabled selected>Select gender</option>
<option>Male</option>
<option>Female</option>
</select>
</div>
<div class="input-field">
<label for="fname">Marital Status</label>
<select name="Marital-Status" required>
<option disabled selected>Select Status</option>
<option>Single</option>
<option>Married</option>
</select>
</div>
<div class="details ID">
<span class="title"></span>
<span class="title">Applicacants Documents</span>
<div class="fields">
<div class="input-field">
<label for="fname">NRC</label>
<input type="file" name="myFile1" placeholder="Enter your email" required style="border: none; background-color: cadetblue;">
</div>
</div>
<div class="fields">
<div class="input-field">
<label for="fname">Bank Statement/Recent Payslip</label>
<input type="file" name="myFile2" placeholder="Enter your email" required style="border: none; background-color: cadetblue;">
</div>
</div>
<form/>
this is my html script form handler
const scriptURL = ‘https://script.google.com/macros/s/AKfycbxs5e-6vCqoK-LhTJNaLq2pjo5BQnFl3bS1N9xnXZzryE2s7aGQS2kGPfryR8V9iucAwQ/exec’
const form = document.forms[‘google-sheet’]
form.addEventListener(‘submit’, e => {
e.preventDefault()
fetch(scriptURL, { method: ‘POST’, body: new FormData(form) })
.then(response => alert(“Thanks for Your Application..! We Will Contact You Soon…”))
.catch(error => alert(‘Error! in Submitting Details, Please try Again’, error.message))
form.reset()
})
and the google site script
var sheetName = ‘Sheet1’
var scriptProp = PropertiesService.getScriptProperties()
function intialSetup () {
var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet()
scriptProp.setProperty('key', activeSpreadsheet.getId())
}
function doPost (e) {
var lock = LockService.getScriptLock()
lock.tryLock(10000)
try {
var doc = SpreadsheetApp.openById(scriptProp.getProperty('key'))
var sheet = doc.getSheetByName(sheetName)
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]
var nextRow = sheet.getLastRow() + 1
var newRow = headers.map(function(header) {
return header === 'Date' ? new Date() : e.parameter[header]
})
sheet.getRange(nextRow, 1, 1, newRow.length).setValues([newRow])
return ContentService
.createTextOutput(JSON.stringify({ 'result': 'success', 'row': nextRow }))
.setMimeType(ContentService.MimeType.JSON)
}
catch (e) {
return ContentService
.createTextOutput(JSON.stringify({ 'result': 'error', 'error': e }))
.setMimeType(ContentService.MimeType.JSON)
}
finally {
lock.releaseLock()
}
}