addFilter Rename ZendFramework

耗尽温柔 提交于 2019-12-11 16:47:13

问题


i need to Rename a file with Zend_File_Transfer() only if new file match with old one in the server using some convention like newfile-1.ext where the -1 is the string that is added but Rename filter is strange, i really dont understand so good.

For example, is necesary some like this:

if(file_exists($file)){
 $upload->addFilter('Rename', $file);
}

or Rename does it?

thanks


回答1:


Here is an example from one of my apps. File is recvieved by an Zend_Form

        $upload->receive();
        $name = $upload->getFileName();

        $newFile = 'mynewfile.xyz'

        $filterFileRename = new Zend_Filter_File_Rename(array(
            'target'    => $this->path . $newFile, // path to file
            'overwrite' => true
        ));
        $file = $filterFileRename->filter($name);


来源:https://stackoverflow.com/questions/9712196/addfilter-rename-zendframework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!