I’m writing a plugin where I get data from a database via an api endpoint and display it in a panel view. That part is working fine. But now I want to add a file upload on the same panel view where you can update the database from a csv file.
My reasoning was: I write a component with a file input, and on submit post it to a custom api route where I parse the csv and update the database.
But I can’t figure out how to post the csv to my api endpoint using Kirby stuff. From what I gather, this.$api.post()
doesn’t allow you to post a file and when I use the <k-upload>
component, the upload is successful but the response is undefined
, even if my endpoint just returns some json so I have no idea what happens there.
I got it to work with a plain XMLHttpRequest()
, but it leaves me wondering if there’s an easier/cleaner approach?