Fileupload over routes

I like to uploads files via extension router. But it breaks after 20Kb and i get an 404. Is there a time/size-limitation? Is there another way to do this?

What does that mean? The logic for uploading is in a route?

Yes, exactly. Here is a thing to test:

'routes' => [
        'pattern' => 'upload',
        'method' => "POST",
        'action'  => function () {
            return $_FILES;

It works only with small files.

Hm, but in the Panel, you can upload large files?

Yes, but not as public user via a form.

Are you authenticating your upload request (either user logged in or impersonated user via $kirby->impersonate()`?

I’m working on my Form Block Plugin (again).

To be more flexible, i need to validate the form via Javascript over an Api. But i need an Interface for that with all the Kirby instances available.

Files need to be stored in the Content-Folder. There’s already a few safety thing inside, to prevent an attack of the panel.

Do you have an idea?

To answere you question: I’m using $kirby->impersonate()

Have you checked the error logs?

No errors here. The parameters upload_max_filesize , post_max_size and memory_limit are on the top.

Well, yes, that’s why I was asking if you could upload bigger files via the Panel.

Hm, I have no clue. Does it work if you do a simple frontend upload, without any JavaScript involved? If yes, then I would assume that there is some sort of error in your code.

Yes, there is a bug anywhere else. It’s hard to debugging trough routers.
I keep on working on it and let you know.

Are you familiar with xDebug? Should help you to debug this.

Tried. I just can’t get the xDebug to run on my Mac. I would need a debugger to debug the debugger. :see_no_evil:

The maybe use Ray app or it’s open-source alternative Kint

I just getting xDebug running. How could i do only one single line of code without it. I saves me thousands of hours escaping vars by switching Browser ↔ VsCode.

You save my day (again), Sonja :raised_hands:

This will bring my extensions development to the next level! :rocket:

The solution: Use multipart/form-data encryption:

<form action="fileupload.php" enctype="multipart/form-data" method="post">
   <input id="file" name="fileToUpload" type="file" />
   <button name="submit" type="submit"> Upload File </button>

And just like to share a link for does, who likes to improve php scripting with xDebug:

Also wrote by Texnixe… Thank you :wink:

Just a short thing about xDebug. Newer versions of Kirby send a lock request every 5 Seconds. To avoid opening a new request tab in VScode i using this configuration:


    "version": "0.2.0",
    "configurations": [
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "maxConnections": 1

@texnixe: Is this a good workaround? What in your config?