Upload file from subpage to site

Hey at all :slight_smile:

I just built my panel via the pagebuilder.

I can choose there if I want to get an global img or an img from the site.
the only difference is that I added a query to image global.

name: image global # no need i guess
fields:
  image_global_data:
    type: files
    query: site.images #queries global images
    layout: list
    uploads:
      template: image
    image:
      ratio: 1/1
      cover: true

All of this works fine!
When I choose image global it shows only the global images
query: site.images #queries global images
But when I upload it uploads the img to the page…
How can I define that it should upload the images to the site as well?

Best and have a nice weekend :slight_smile:
Marvin

You can define the destination for the uploaded file, see https://getkirby.com/docs/reference/panel/fields/files#upload-options

But you can only define one upload destination, not multiple, so either - or. If you really need the files in both destinations, you would have to use an file.upload:after hook to actually copy the file to another destination.

1 Like

So do I understand it right that I only can use one upload option a page?
And not different upload destinations for two different page builder file blocks?

I’m afraid I don’t really understand. The page builder field is no upload destination?

To bring it to the point:
I have two different file templates in my backend. One for page images and one for global:

The page Template:

name: image page # no need i guess
fields:
  image_page_data:
    type: files
    layout: list
    uploads:
      template: image
    image:
      ratio: 1/1
      cover: true

and the global template:

 name: image global # no need i guess
    fields:
      image_global_data:
        type: files
        query: site.images #queries global images
        layout: list
        uploads:
          template: image
        image:
          ratio: 1/1
          cover: true

now I want, if I upload an img “in” the global template I want to store the img global
and if I upload an img via the page template to be stored in the page itself.

Same like: if I select an img from page template I get only the images already stored in the page and if I select an img from global template I get only the images stored on the site itself (globally). I want the same with uploading the imgs

So that in the end I could upload images in my subpages but make it globally accessible.

PS: do u have a Kirby affiliate link?

As I sid before, you can define to where an image is uploaded to via the uploads option of the field.

  uploads: 
    parent: site # to upload to the global site images
    template: image

Since uploading to the current page is the default, there is no need to set this explicitly.

Yes, if you click on my profile…

1 Like