Upload plugin: dir not create sub folder

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

The default value for the path option is webroot{DS}files{DS}{model}{DS}{field}{DS} .

$this->addBehavior('Josegonzalez/Upload.Upload', [
    'poster' => [
        'path' => 'webroot{DS}files{DS}{model}{DS}{field}{DS}photo_dir{DS}'
    ]
]);