如何上传文件,将其移动到目录并在覆盖任何现有文件时保留文件名?在Zend Framework中。
这维护了tmp文件名(如php3382.tmp)
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination('data/');
$adapter->addFilter('Rename', array(
'target' => 'data/',
'overwrite' => true
));
$adapter->receive();
并且不会覆盖
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination('data/');
$adapter->receive();
答案 0 :(得分:1)
试试这个:
...
$adapter->addFilter('Rename', array('overwrite'=> true,
'target'=> sprintf('data/%s',
$adapter->getFileName()),
));
$adapter->receive();
....