Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

How can I upload files to a collection

default discord avatar
japineda162 years ago
4

Hi! I need to upload a list of products, using the API, I'd like to know if exist some way to upload files directly to a POST query? I'd like to add saying that file file structure is contained in an array in my collection in PayloadCMS



I’ve reed the official doc of upload in payload, but it didn’t work, what am I doing wrong?

  • discord user avatar
    jarrod_not_jared
    2 years ago

    You need to post the file data to the media collection first, which will return an ID, and then you can use that on your array field

  • default discord avatar
    taongab2 years ago

    please help, this is exactly what i am trying





    however, in payload, my image is :



    grayed out

  • discord user avatar
    jarrod_not_jared
    2 years ago
    @915584690604359691

    you are posting that data? try:


    photos: ["64381f9003fd801b47d54391"]
  • default discord avatar
    taongab2 years ago

    hey thanks for your reply. The screen capture is from Postman. The challenge is that when i try without specifying the id, i get this error:





    this is how i defined the field:





    found the solution:

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.