我想更改上传文件名。以下是我写的代码:
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination(IMAGE_PHY_PATH);
try {
//upload received file(s)
$upload->addFilter('Rename', array('target' => IMAGE_PHY_PATH."1.jpg",
'overwrite' => true));
$upload->receive();
} catch (Zend_File_Transfer_Exception $e) {
$e->getMessage();
}
有谁能告诉我我的代码有什么问题?
答案 0 :(得分:1)
$rename = new Zend_Filter_File_Rename(array(
'target' => IMAGE_PHY_PATH . '1.jpg',
'overwrite' => true
));
$upload->addFilter($rename);
答案 1 :(得分:0)
试试realpath(IMAGE_PHY_PATH)
。这应该产生绝对路径名(例如:$adapter->setDestination('C:\temp')
)。
在此检查之后查看路径是否存在且是否可写。通常,如果不是这样,setDestination应抛出异常。如果路径正确,请在try / catch块之后调用$ form-> getValues()。