0

I have a custom HTML page from which I can select a file and upload. The app script gets the file and uploads it to Drive. But when I do this all the images are uploaded in an unsupported format. I download the file from the drive app and when I open it on the windows desktop, it says unsupported format.

Can someone help here, please

HTML file

<input type="file" id="cImg" name="cImg"/>
<input type="submit" value="Submit" class="btn btn-primary" id="btnSave" />

Java script

form.addEventListener('submit', e => {
    e.preventDefault();
    if(form.checkValidity()) {      
       google.script.run.withSuccessHandler(FormReset).SaveComplaint(form);
    }
    else {
      form.reportValidity();
    }   
  })

App Script

function SaveComplaint(form)
{
  var fileBlob = form.cImg;
  var folder = DriveApp.getFolderById('XXXXXXXX'); // Drive Folder ID
  var upFile = folder.createFile(fileBlob);
}
Sam K
  • 332
  • 1
  • 6
  • 19
  • From your script and situation, I thought that the reason of your issue might be due to V8 runtime. If it's so, how about enabling V8 runtime at the script editor and test it again? Or, when you want to use V8 runtime, [this thread](https://stackoverflow.com/q/60742695) might be useful. – Tanaike Nov 19 '20 at 04:06
  • Can you see the image in your Drive? What file format is downloaded into your local environment ? – Mateo Randwolf Nov 19 '20 at 08:36
  • @MateoRandwolf it is downloaded in the same format as uploaded – Sam K Nov 19 '20 at 16:54
  • @Tanaike not sure what do you mean by v8 server, when i see my script, i see a message that "This project is running on our new Apps Script runtime powered by Chrome V8." – Sam K Nov 19 '20 at 16:56
  • Thank you for replying. I have to apologize for my poor English skill. If you had already enabled the [V8 runtime](https://developers.google.com/apps-script/guides/v8-runtime) at the script editor, when it is disabled, what result will you obtain? Or, when you want to use V8 runtime, [this thread](https://stackoverflow.com/q/60742695) might be useful. – Tanaike Nov 19 '20 at 23:14
  • Hi ! Could you please share the resto of the sample code (without providing any sensitive data) specially regarding to your ```HTML``` form and how you handle it so that we can try to reproduce your behaviour as accurately as possible ? Thanks ! – Mateo Randwolf Nov 23 '20 at 15:37

0 Answers0