I need to upload a file on google drive from a web app. I found on the internet this code which is working for others but not for me since it actually creates the file on Drive but the content is always blank.
The code is this:
function upload(e) {
var destination_id = "1AnosRSXyYiOcSLYxBMbjPMEHepHehct6";
var img = e.myFile;
var destination = DriveApp.getFolderById(destination_id);
var createFile = destination.createFile(img);
return createFile.getUrl();
}
while on client side it is:
<div>
<form>
<input type="file" id="thefile" name="myFile"multiple>
<input type="button" value="Upload" id="submitBtn">
</form>
</div>
<script>
document.getElementById('submitBtn').addEventListener('click',function(e){google.script.run.withSuccessHandler().upload(this.parentNode)});
<script/>
any idea?