1

我想更改上传文件名。下面是我写的代码:

 $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();
 }

谁能告诉我我的代码有什么问题?

4

2 回答 2

1
$rename = new Zend_Filter_File_Rename(array(
    'target'    => IMAGE_PHY_PATH . '1.jpg',
    'overwrite' => true
));

$upload->addFilter($rename);
于 2012-04-10T07:03:16.267 回答
0

Try realpath(IMAGE_PHY_PATH). This should produce an absolute pathname (ex: $adapter->setDestination('C:\temp')).

After this check to see if the path exists and is writable. Normally setDestination should throw an exception if not so. If the path is correct call $form->getValues() after the try/catch block.

于 2012-04-10T20:56:43.593 回答