Image base64 create file

At the moment im working on a a image upload over frontend - I get all data.
But I got stock on using base64 as source - That is what i have so far.

I got this error back
1. message: “Argument 1 passed to Kirby\Filesystem\Mime::matches() must be of the type string, null given, called in /vendor/getkirby/cms/src/Filesystem/File.php on line 311”

                    //Create Images
                    $submissionDirectory = $submission->contentFileDirectory();

                    foreach($images as $image){
                        $base64 = explode(',',$image['dataURL']);
                        $filename = $image['name'];
                        $file = file_put_contents($submissionDirectory . '/' . $filename, base64_decode($base64[1]));
                      
                        $submission->createFile([
                            'source'   => $file,
                            'filename' => $image['name'],
                            'template' => 'image',
                            'content' => [
                                'titel' => $image['caption']
                            ]
                        ]);
                    }

Thats my array

Ok i do it now like here → Kirby3-Gilmour/index.php at master · HashandSalt/Kirby3-Gilmour · GitHub
and it works