Trying to enable upload of JavaScript files via plugin

I’m trying to enable uploading of JavaScript files via a files field in a plugin blueprint:

scriptFile:
  type: files
  label: Script file
  required: true

I’ve tried enabling .js file uploads in the plugin’s index.php, according to the documentation:

Kirby::plugin('foo/bar', [
  'fileTypes' => [
    'js' => [
      'mime' => 'text/javascript',
      'type' => 'code',
    ],
  ]
]);

But without success, uploading a .js file keeps throwing the Invalid file type: code error

Have I missed something?

Sidenote, the documentation contains a dead link: https://getkirby.com/docs/guide/content/files#example-page-with-files__supported-file-types

Have you tried to add a file blueprint that explicitely allows the extension (and then set this template your scriptFile field?

This is necessary, because by default, only certain file types are supported for upload.

Thanks for the hint with the wrong link, will fix.

That was it, I had to add a file blueprint with the extension enabled :+1: