Unknown type "upload.file"
enviniom opened this issue · 2 comments
enviniom commented
Hi. I am using CakePHP 4 and this plugin to upload files. I configured the plugin (V 5.0.0 RC) with the advanced configuration adding a behavior in the table as shown in the docs, as follows
$this->addBehavior('Josegonzalez/Upload.Upload', [
'pdf' => [
'fields' => [
'dir' => 'pdf_dir',
],
'nameCallback' => function ($table, $entity, $data, $field, $settings) {
$extension = pathinfo($data['name'], PATHINFO_EXTENSION);
return strtolower("ot" . "-" . Time::now()->i18nFormat('yyyy-MM-dd.HH:mm:ss') . '.' . $extension);
},
'deleteCallback' => function ($path, $entity, $field, $settings) {
// When deleting the entity, both the original and the thumbnail will be removed
// when keepFilesOnDelete is set to false
return [
$path . $entity->{$field},
];
},
'keepFilesOnDelete' => false
],
]);
Saving a new record without a file works fine, but when uploading a file I get the error:
Unknown type "upload.file"
InvalidArgumentException
ADmad commented
You need to load the plugin using $this->addPlugin()
in your Application::bootstrap()
.
angelxmoreno commented
I was encountering this issue but only during tests. After some digging I was able to resolve it thanks to #574