我正在尝试使用 rename-addFilter 重命名上传的文件。实际上传已经可以了,但是文件只是上传并没有重命名,那么我该怎么做呢?这是我的控制器代码,用于上传文件:
//Getting the new filename, works perfectly:
$name = explode('.', $form['pic']);
$ext = $name[1];
$mapper = new Application_Model_CmsMap();
$row = $mapper->fetchRow('childId = "' . $id . '" AND type= "pic"');
$new_filename = $row->name.'.'.$ext;
//All images will and are be stored in /public/images/
//Maybe the picture should be replaced, so it should be overwrited, in case it already exists
$upload->addFilter('Rename', array(
'target' => '/images/'.$new_filename,
'overwrite' => true,
)
);
$upload->receive();