Uploading Image to Google Form Errors -
i've been struggling this. very new writing code, bear me.
i want create form file submission parsers responses google spreadsheet , places file specific folder in my gdrive, not uploader's gdrive.
i've have tried debugging , asking around, no 1 can seem figure out error or how place uploaded files own folder, can have access them/see them.
here link code: https://script.google.com/d/appid/edit?usp=sharing
i can't figure out what's wrong.
here can offer simple script copy fileupload in folder wish , write value textfield sheet.
it written simple can give first steps.
copy code in scripts file , run google apps script. before run scripts have change in code uloadfolder id , id sheet. find own id's when browse these elements in googledrive , read id's urlpath in browser.
function doget() { var app = uiapp.createapplication(); var text_lbl = app.createlabel('text: *'); var text = app.createtextbox().setname('text'); var replay_file_lbl = app.createlabel('replay upload:'); var replay_file = app.createfileupload().setname('replay_file'); var submit_btn = app.createsubmitbutton('submit'); var battle_result_tbl = app.createflextable(); battle_result_tbl.setwidget(0, 0, text_lbl) .setwidget(0, 1, text) .setwidget(1, 0, replay_file_lbl) .setwidget(1, 1, replay_file) .setwidget(4, 1, submit_btn); var form_panel = app.createformpanel() .setwidget(battle_result_tbl); app.add(form_panel); return app; } function dopost(e) { var app = uiapp.getactiveapplication(); // uploads writen in root folder of google drive var upload_root = docslist.getfolder(''); // dest folder uploads files var upload_folder = docslist.getfolderbyid('0b4kg6cmbounaohlmtxzumuptn3c'); var text = e.parameter.text; var replay_file = e.parameter.replay_file; var thx_lbl = app.createlabel('thanks submission!'); app.add(thx_lbl); // workaround, use try & catch cause if no file uploaded error "file name cannot empty" try{ var replay_file_id = docslist.createfile(replay_file); // create uploaded file replay_file = replay_file_id.getid(); // id uploaded file replay_file_id.addtofolder(upload_folder); // copy uploaded file root dest folder replay_file_id.removefromfolder(upload_root); // delete uploaded file root folder } catch(e){logger.log('replay_file: '+e.message);} // open ur sheet id write value of text in var ss = spreadsheetapp.openbyid('1-c4mkf2tligtmguwnk45df51ozblgi0xk5bkvuwxrh8'); // write value formelement text cell a1 ss.getactivesheet().getrange(1,1).setvalue(text); return app; }
Comments
Post a Comment