I have a custom UI function, that opens a modal dialog in my Google Sheets file. The modal is a simple HTML with a form, that allows the user to choose a file from local hard drive, to upload it into Google Drive. The HTML part for this form is as follows:
<form>
<input type="file" name="theFile" id="file-check" accept="image/*">
<input type="button" class="btn btn-info" value="Add photo" id="add-image">
</form>
And the code for sending the data is as follows:
$("#add-image").click(function(){
var val = $('#file-check').val();
if (val == ''){alert('Choose a file to upload');return;}
$('#add-image').attr("disabled", true);
$('#add-image').attr("value", "Adding... please wait.");
google.script.run.withSuccessHandler(refreshIt).withFailureHandler(show_error).uploadImage(this.parentNode);
});
But when I submit the form, the response from the server is this:
{theFile=null}
I've tried to set up this modal dialog as a standalone web-app and it's working normally... The response from the server from the standalone webapp is as follows:
{theFile=FileUpload}
And the file is being uploaded without any problems!
Why is it working normally as a standalone webapp but sending the null as a modal dialog?