На моих файлах модель:
var $actsAs = array(
'Uploader.FileValidation' => array(
'file' => array(
'extension' => array('gif', 'jpg', 'png', 'jpeg'),
'filesize' => 5242880,
'required' => true
)
),
'Uploader.Attachment' => array(
'file' => array(
'uploadDir' => 'upload/', // Where to upload to, relative to app webroot
'dbColumn' => 'path', // The database column name to save the path to
'maxNameLength' => 30, // Max file name length
'overwrite' => true, // Overwrite file with same name if it exists
'name' => '', // The name to give the file (should be done right before a save)
'transforms' => array() // What transformations to do on images: scale, resize, etc
)
)
);
А на контроллере:
$this->File->Behaviors->Attachment->update('File', 'file', array('name' => 'testing')));
if ($this->File->save($this->data)) {
Файл загружен нормально, а запись сохранена в базе данных.Но я хотел переименовать файл, чтобы люди не могли найти архивы по ошибке.
Спасибо!