I try to build condition to check either the file is uploaded before submit. Current situation is, it success to send/submit either file uploaded or not. When I try to get the file use var file = e.parameter.file
, it give a string FileUpload
. Can anyone help me?
function setFormUpload() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var app = UiApp.createApplication().setTitle("Upload File");
var form = app.createFormPanel().setId('form').setEncoding('multipart/form-data');
var formContent = app.createVerticalPanel();
var infoBox = app.createLabel().setVisible(false).setId('infoBox');
form.add(formContent);
formContent.add(app.createFileUpload().setName('file'));
formContent.add(app.createSubmitButton('Upload'));
app.add(form);
sheet.show(app);
}
function doPost(e){
var app = UiApp.getActiveApplication();
var file = e.parameter.file;
if(file == ''){
var text = 'file empty';
} else {
var text = 'file exist';
}
app.getElementById('infoBox').setText(text).setVisible(true);
return app;
}