How do I view images in HTMLservice?

Asked 2 years ago, Updated 2 years ago, 59 views

I wrote the following code, but I can't see the image. Why?
The image is in Google Photo under My Drive

.

Code .gs side

function getPic(idStr){
  varfile=DriveApp.getFileById(idStr);   
  varimTag=';


  imgTag+='<p><img src="'+file.getBlob()+'"id="image-box"/>/p>' 

  // file.getBlob() is also not displayed as file.getUrl().
  return(imgTag);
}

showPic.html side

<input type="button" value="getPic" onclick="google.script.run.withSuccessHandler(onSuccessImg).getPic('fileID_string')">  

function onSuccessImg(res){       
  varimgBox= document.getElementById("image-box"); 
  imgBox.innerHTML=res;        
}

<html>
<body>
   <p><img src="xxxx" id="image-box"/></p>
</body>
</html>

google-apps-script

2022-09-30 20:18

1 Answers

File ID seen from https://drive.google.com/uc?export=view&id=GoogleDrive

If it is the URL of , it should be displayed

"From Google Drive" is Kimo.


2022-09-30 20:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.