2

如何上传文件,将其移动到目录并在覆盖任何现有文件时保留文件名?在 Zend 框架中。

这维护了 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();
4

1 回答 1

1

试试这个:

...

$adapter->addFilter('Rename', array('overwrite'=> true,
                                    'target'=> sprintf('data/%s', 
                                                       $adapter->getFileName()),
                                    ));
$adapter->receive();

....
于 2012-07-06T15:11:26.477 回答