Upload an image to a Google spreadsheet

后端 未结 5 987
长情又很酷
长情又很酷 2020-11-30 06:59

I am making a photo shooting contest, the competitor should register using a Google registration form, and upload his photo as well. I searched all over the internet to find

5条回答
  •  孤街浪徒
    2020-11-30 07:38

    To get a direct link to the image in the spreadsheet, use the getID function instead of getUrl and prepend the URL to Gdrive.

    Change this:

    var targetRange = sheet.getRange(lastRow+1, 1, 1, 4)
        .setValues([[ListVal,textVal,Email,img.getUrl()]]);
    

    To this:

    var targetRange = sheet.getRange(lastRow+1, 1, 1, 4)
       .setValues([[ListVal,textVal,Email,"https://drive.google.com/uc?export=view&id="+img.getId()]]);
    

提交回复
热议问题