milesj/cake-uploader — Issue #34: using saveAll for hasMany images
Author: designvoid
Created: 2012-01-06 13:13:06+00:00
State: open

I am using the 1.3 version of the plugin.

I have NewsPosts and they have many NewsImages

My form has:

```
echo $this->Form->input('NewsImage.fileName', array('type' => 'file'));
```

And I'm using saveAll in the NewsPosts controller

The file is being uploaded but the info is not being saved correctly in the NewsImages table. After doing a few debugs, I have found that the data array in the beforeSave in attachment.php is incorrectly formatted:

```
Array
(
[NewsImage] => Array
(
[fileName] => Array
(
[name] => Blue hills.jpg
[type] => image/jpeg
[tmp_name] => C:\Program Files\Wamp\tmp\php70.tmp
[error] => 0
[size] => 28521
[news_post_id] => 4027
)

[modified] => 2012-01-06 13:05:13
[created] => 2012-01-06 13:05:13
[modified_by] => 5
[created_by] => 5
[upload_path] => /img/news_images/Blue_hills4.jpg
[group] => image
[width] => 800
[height] => 600
)

)
```

I have the following in my NewsImage model:

```
var $actsAs = array(
'WhoDidIt',
'Uploader.Attachment' => array(
'fileName' => array(
'name'	=> '',
'baseDir'	=> '',
'uploadDir'	=> 'img/news_images/',
'dbColumn'	=> 'upload_path',
'importFrom'	=> '',
'defaultPath'	=> '',
'maxNameLength'	=> 30,
'overwrite'	=> false,
'stopSave'	=> true,
'transforms'	=> array(),
's3'	=> array(),
'metaColumns'	=> array(
'group'	=> 'group',
'width'	=> 'width',
'height'	=> 'height'
)
)
),
'Uploader.FileValidation' => array(
'fileName' => array(
'maxWidth'	=> 1000,
'maxHeight'	=> 1000,
'extension'	=> array('gif', 'jpg', 'png', 'jpeg'),
'filesize'	=> 5242880,
'required'	=> false
)
)
);
```