You can use Google Apps Script to upload images to Google Drive and retrieve the URL of the uploaded image, then populate the URL into a Spreadsheet.
Here are the steps you can follow:
Create a new Google Spreadsheet.
Open the Script Editor from Tools > Script Editor.
Write the below code:
function uploadImage() {
var folderName = "Images"; // Replace "Images" with your folder name in Google Drive
var folder = DriveApp.getFoldersByName(folderName).next(); // Get the folder by name
// Show the file upload dialog box
var ui = SpreadsheetApp.getUi();
var response = ui.prompt("Please enter the URL of the image to be uploaded:", ui.ButtonSet.OK_CANCEL);
if (response.getSelectedButton() == ui.Button.OK) {
var imageURL = response.getResponseText();
// Create an image file and upload it to the folder
var blob = UrlFetchApp.fetch(imageURL).getBlob();
var file = folder.createFile(blob);
// Get the URL of the uploaded file
var fileURL = file.getUrl();
// Populate the URL in the active cell of the Spreadsheet
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var activeCell = sheet.getActiveCell();
activeCell.setValue(fileURL);
}
}
Save the script and give it a name, for example, ‘ImageUploader’.
Go back to the Spreadsheet and select a cell in a column where you want to store the image URLs.
From the menu, go to Tools > Macros > ImageUploader.
A dialog box will appear that prompts you to enter the URL of the image you want to upload. Enter the URL and click OK.
The image will be uploaded to the folder specified in the code, and the URL of the uploaded image will be populated in the active cell of the Spreadsheet.
You can repeat the process for as many images as you want to upload.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-05-05 11:00:00 +0000
Seen: 9 times
Last updated: Feb 17 '22
On RemixIDE, what do the terms Gas, transaction cost, and execution cost mean?
What is the process for preserving all Docker images and transferring them to a different device?
What are the ways to prevent image distortion in react native's flatlist?
What is the reason that Laravel is unable to upload images to s3, while it is able to retrieve them?
Can selfbot messages in discord.js have locally uploaded images attached to them?
How can images be uploaded using Firebase when there is no internet connection?
Why are the public images not appearing on dynamic routes in NEXTJS?
What is the process for transferring the docker images directory to a remote server?
How can I delete all rows and columns that are grouped together in a spreadsheet?