Hi, I’m a newbie using Cake. I am having problems trying to upload files using josegonzalez/upload plugin.
I have an error when I try to upload a file in my project:
Error: [InvalidArgumentException] Invalid data type, must be an array or \ArrayAccess instance.
Here is the code i use in my table:
public function initialize(array $config)
{
parent::initialize($config);
$this->setTable('resoluciones');
$this->setDisplayField('nombre');
$this->setPrimaryKey('id');
$this->addBehavior('Josegonzalez/Upload.Upload', [
'ruta' => [
'path' => 'webroot{DS}resoluciones',
'nameCallback' => function ($table, $entity, $data, $field, $settings) {
$msec = explode(" ", microtime(false));
$ext = preg_split("/[\.]+/", $data['name']);
$NameEncript=Security::hash($data['name'].$msec[0], 'sha1', true);
return $NameEncript . '.' . end($ext);
},
'keepFilesOnDelete' => false,
'keepFilesOnUpdate' => false,
],
]);
}