Automatically retrieve image URL after upload

brain = mush. Help needed.

I have a user-generated dataset populated via form. Part of the upload is an image. Is there an easy – or any – method to find and return the the image url after it’s uploaded? The dataset only shows a thumbnail of the image itself so I don’t know if the query should happen there, or via the media manager.

@jana9340 When you query that field or refer to the field in a dataset in code, the value will be the url. A quick example where “pets” is the name of the collection:

import wixData from "wix-data";

$w.onReady(function () {
  wixData.query("pets")
    .isNotEmpty("petPhoto")
    .find()
    .then((results) => {
        console.log(results);
        console.log(results.items[0].petPhoto);
        console.log(results.items[1].petPhoto);
  })
});

@tony-brunsman

Two things I’m hoping you can help with.

  1. I’m getting a 403 Forbidden error in the console log with the code above. Any ideas why the server is refusing to authorize the request?

  2. If the server does return the proper URL, instead of putting the results into the console log, I’d like to add them to a specific field in the dataset for the pet the image was uploaded for. I do not want to replace the image, but want the URL as a separate column. (Also, it needs to be the ‘real’ URL, not the one that links back the the media manager.)

Thank you!

  1. No idea why you’re getting the 403 error with that code.

  2. I refer you to this post .

@tony-brunsman Thanks, checking it out now!