Upload GPX file, invalid type

Hi I am trying to upload .GPX files to the files in a blueprint but it is not possible and displays the error Invalid file type: -. Any other file type seems to works fine. I am using the preset: page.

The blueprint is

title: Default Page Builder
preset: page
template: layouts
fields:
  ...

I also tried

title: Default Page Builder
preset: page
files:
  accept:
    extension: gpx
 ...

without success, but in general it should allow pretty much all types, best case

AFAIK extension is not a valid property for a Files section. You’d have to define a File blueprint, e.g. as site/blueprints/files/gpxfile.yml:

title: GPS track
accept:
  mime: text/xml, application/gpx, application/gpx+xml

…and then reference that blueprint template in your page blueprint:

title: Default Page Builder
preset: page
files:
  template: gpxfile
 ...

You may also create the file blueprint as site/blueprints/files/default.yml, in which case it should override Kirby’s default file blueprint (but then all File fields on your entire site will use those rules, so my preferred approach is to create a dedicated File blueprint for special cases).

Hi Sebastian

Thanks for your response. I already tried this method as well (without text/xml initially but just tried this now as well), and this does not work for me either. In this case, I cannot even select a GPX file from the upload selector. Everything is greyed out.

Also, in the end I need to be able to upload various file formats, not only GPX files. It would almost be best if there was a way to enable all files.

EDIT: Somehow when I override the default.yml it works. I will do this for now and see why it is not taking the right file template yml.

According to File blueprint | Kirby , “allow all files” should be possible with accept: true (I somehow recall that some limitations remain, e.g. uploading an HTML file will still cause an error, I believe…).

Hmm, good to hear it works, but strange that you cannot define your own template. In principle, I use that setup with GPX on my own site (hence the tested-and-proven mime definition :wink:) – so maybe it’s something to do with the preset mechanism …that’s not my strong suit.

1 Like

@sebastiangreger, out of interest, what did you use to visualise the GPX on the frontend?
Is your website publicly accessible online somewhere?

Thx!

@bvdputte At the moment I simply display it on a map; I use Mapbox GL JS with self-hosted vector tiles from OpenMapTiles to display them on a map …all very experimental and just for my private exploration at this point – unfortunately I don’t currently have a publicly accessible sample to show that includes a GPX track.

I always wanted to try out https://github.com/Sibyx/phpGPX but have yet to find some time to experiment.

If you’re interested, I’ve used Leaflet with MapBox Tiles, and this plugin.

1 Like

Thanks all. I might get back asking for more info about this.

I’ve always wanted to sortof embed gpx files in a website.

Can you tell a bit about the integration of the map into the Kirby website. Are you using a Kirby plugin? Or is that built into the site’s template?