I’m using CakePHP upload plugin for CakePHP 4. I’ve needed to upload a poster to the project. the field is configured as ‘poster’ and ‘poster_dir’ to store the directory.
The model has been configured:
$this->addBehavior('Josegonzalez/Upload.Upload', [
'poster' => [
'fields' => [
'dir' => 'poster_dir',
],
],
]);
The form has been configured to type=‘file’. However, the poster directory will save the directory only without create a folder based on ID eg: webroot\files\Documents\poster\
I’ve used the path as shown below:
$this->addBehavior('Josegonzalez/Upload.Upload', [
'poster' => [
'path' => 'webroot{DS}files{DS}{model}{DS}{field}{DS}{primaryKey}',
'fields' => [
'dir' => 'poster_dir',
],
],
]);
it shows an error:{primaryKey} substitution not allowed for new entities
How can I solve these issues? Thanks