How to get complete file path from typo3 custom extension?
14,842
Solution 1
You could also retrieve the path through the API
$fileName = 'foo.jpg';
$basePath = t3lib_div::getFileAbsFileName('uploads/tx_templavoila/');
$file = $basePath . $fileName;
However, as of TYPO3 6.0 this will become:
$fileName = 'foo.jpg';
$basePath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('uploads/tx_templavoila/');
$file = $basePath . $fileName;
Solution 2
Check your ext_emconf.php
there should be a configuration entry for creating the necessary directories like in TemplaVoila:
...
'createDirs' => 'uploads/tx_templavoila/',
...
If you need the absolute Filepath you can always use the constant PATH_site
, e.g. check if an image exists (assuming $data is filled with the whole row and you are checking for the filename in 'image'):
if(is_file(PATH_site . 'uploads/tx_yourextensionname/' . $data['image'])){
// your code here
}
Author by
user911282
Updated on June 14, 2022Comments
-
user911282 almost 2 years
I am developing custom typo3 extension, i have include file browse option (using kickstarter ) in my plug-ins. I stores only filename. How do i find the complete path of the file?
Generally, typo3 text,text/image elements uploads files into uploads/ directory. How can i do that ?
Thanks.