I cannot open the uploaded file and I strictly follow Google Guide's instruction:
which are
//under Basic interact.gs
function doGet() {
return HtmlService.createHtmlOutputFromFile('Index');
}
function processForm(formObject) {
var formBlob = formObject.myFile;
var driveFile = DriveApp.createFile(formBlob);
return driveFile.getUrl();
}
AND
//under index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
// Prevent forms from submitting.
function preventFormSubmit() {
var forms = document.querySelectorAll('form');
for (var i = 0; i < forms.length; i++) {
forms[i].addEventListener('submit', function(event) {
event.preventDefault();
});
}
}
window.addEventListener('load', preventFormSubmit);
function handleFormSubmit(formObject) {
google.script.run.withSuccessHandler(updateUrl).processForm(formObject);
}
function updateUrl(url) {
var div = document.getElementById('output');
div.innerHTML = '<a href="' + url + '">Got it!</a>';
}
</script>
</head>
<body>
<form id="myForm" onsubmit="handleFormSubmit(this)">
<input name="myFile" type="file" />
<input type="submit" value="Submit" />
</form>
<div id="output"></div>
</body>
</html>
I can upload the file (say photo.jpg with 5kb) using the index.html. After the uploading, I could find (photo.jpg with 8kb) in https://drive.google.com/drive/my-drive. However, I cannot open the file (photo.jpg with 8kb) by previewing in Google Drive or by opening the file after downloading. (Error message: Paint cannot read this file. This is not a valid bitmap file, or its format is not currently supported)
The same problem when I tried a docx file. (Before upload: 45kb) (After upload: 79kb) (Error message#1: Word found unreadable content. Do you want to recover the contents of this document?)(After pressing Yes: Word experienced an error trying to open the file. Try these suggestions. Blablabla)
I do not know what to do next when I strictly follow the Google Guide.
Please help me..I am new to everything.Thank you.
And sorry for my poor english T^T