#96780rename file in server
Description
hi evreybody
how can i rename a file in server? I wanted to change an uploaded file with another file… i changed the contet of the old one into new file with below code:
$fileReference = $this->resourceFactory->getFileReferenceObject( $id);
$file=$fileReference->getOriginalFile();
$file->setContents($content);
i see the new file now in frontend but i want to change the name of file too? how can i do it?
i dont wanted to delete the file and add a new file beacuse i dont want to increase id in sys-table and etc…..
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 5
-
razieh zivaralam changed subject
rename folderrename file in server 02/08/22, 09:35 -
Oliver Hader commented 02/08/22, 11:11
-
Oliver Hader changed tracker
FeatureTask statusNewNeeds Feedback Tags pending-close TYPO3 Version 11 02/08/22, 11:11 -
Christian Kuhn commented and changed status
Needs FeedbackClosed 02/19/22, 17:30hey. i hope it’s ok to close here since that was more an API question than a core issue.
-
razieh zivaralam commented 05/03/22, 11:41
thanks
$file->setContents($content);just replaces the (inner) contents of a file, but not the name.The
ResourceStorageis capable of dealing with how and where files are stored – including renaming.see https://github.com/TYPO3/typo3/blob/bc15ad4b24a3c76087a2aa1172d44cb84fe0569c/typo3/sysext/core/Classes/Resource/ResourceStorage.php#L2029-L2038