Using Camera Tool to take a picture, then upload directly to Google Form

Hi all, nice to meet everyone in this community :slight_smile:

I have been trying to use Camera Tool to take a picture, then upload directly to Google Form. But how do I do this?

29342645-24a7-4730-bf3c-50a57470a3c3
794e8d91-a857-455a-b7df-983383c5d40f

If you guys see my first picture, those are the items that users need to fill in, which will then be uploaded onto the google form. This includes taking picture and uploading onto the same google form.

However, when I click submit button on my app, the google spreadsheet (2nd picture) captures everything but not the google drive URL of the image I captured. Nonetheless, the image captured is in my Google Drive.

Please help? <3

Thanks guys I would love you all so much!!

Need to see your relevant blocks, and methods for uploading the image and getting the URL/ID of the image.

Your images are very small/low resolution and illegible.

Hi TIMAI2,

Thanks for the response!

This is my code:


Currently this code only works if my google form does not include the option to upload image.
https://docs.google.com/forms/d/e/1FAIpQLScxEbmW-0yJdked-PKIX5C5KpRla9NZ4kr4MvbOVr1HHqJwqQ/viewform
Using this code, if I fill in the 5 textboxes + 1 spinner, my google spreadsheet will reflect the responses for all 6 of these items. I will also have 6 "entry.xxxxxxxxx=" for all these 6 questions.

However, if I include the option to upload image (as optional), even when I fill in the 5 textboxes + 1 spinner, my google spreadsheet stops capturing any single responses despite the option to upload image is set as optional.

Furthermore, 5 textboxes + 1 spinner + 1 upload image, I would expect to have 7 "entry.xxxxxxxxx=". But when I try to obtain the link, it only gives me 6 of the "entry.xxxxxxxxx=". The entry.xxxxxxxxx for image upload is missing.

The reason why I need to have the 5 textboxes + 1 spinner + 1 upload image in one same google form is so that my app can display all 6 information together with the respective image, as shown below:

You can't upload image directly.
Either upload image online somewhere or (Web) post the image.

This is why I was interested to read that you said the image was uploaded on Google Drive!

You will need to use a different method for the image:

Upload Any File To Google Drive with AI2

Change the last two lines of the web app script to get the file ID:

var FileID = DriveApp.getFolderById('<YOUR FOLDER ID HERE>').createFile(blob).getId();
return ContentService.createTextOutput(FileID);

Then add the FiIeID returned to your google form "7th text box" and upload the data to your sheet

You can construct a URL from the file ID if you want: e.g.

https://drive.google.com/file/d/<file ID here>/view

You might want to consider not using the google form approach at all:

https://groups.google.com/g/mitappinventortest/c/liWppNXqHXM/m/5Ht506yRBwAJ

Thanks TIMAI2!

I will try both methods and will update everyone! Hope it works!! I truly appreciate it :slight_smile:

Hi Tim!

Can I ask, which Script Editor should I put this in?:

function doPost(e) {
var data = Utilities.base64Decode(e.parameters.data);
var blob = Utilities.newBlob(data, e.parameters.mimetype, e.parameters.filename);
var FileID = DriveApp.getFolderById('0B5wEV4Pes_aefnpwQnptSTFnQURBbDVVTUFsbzMyNjZ3bktMaGItaGRPaWdvSHhDeEwxOXM').createFile(blob).getId();
return ContentService.createTextOutput(FileID);
}

I tried putting in both Google Sheets --> Tools --> Script Editor and also Google Sheets --> Form --> Edit Form --> More --> Script Editor, but both don't seem to work. I get the response:

Did I do something wrongly? Thanks!

Probably best to read this:

HOWTO: Create a Google Apps Script Web App bound to a Spreadsheet

How do you resolved it?