{"id":52,"date":"2021-05-11T00:16:01","date_gmt":"2021-05-11T00:16:01","guid":{"rendered":"https:\/\/myport.ddev.site\/blog\/?p=52"},"modified":"2021-05-11T00:16:56","modified_gmt":"2021-05-11T00:16:56","slug":"getting-referenced-files-in-typo3","status":"publish","type":"post","link":"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/","title":{"rendered":"Getting referenced files in TYPO3"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">In the frontend context<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In a frontend context, the&nbsp;<code>\\TYPO3\\CMS\\Core\\DataHandling\\DataHandler<\/code>&nbsp;class cannot be used and there is no specific API to create a File Reference. You are on your own.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The simplest solution is to simply create a database entry into table \u201csys_file_reference\u201d by using directly the database connection class provided by TYPO3 CMS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A cleaner solution using Extbase requires far more work. An example can be found here:&nbsp;<a href=\"https:\/\/github.com\/helhum\/upload_example\">https:\/\/github.com\/helhum\/upload_example<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This snippet shows how to retrieve FAL items that have been attached to some other element, in this case the \u201cmedia\u201d field of the \u201cpages\u201d table:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$fileRepository = GeneralUtility::makeInstance(\\TYPO3\\CMS\\Core\\Resource\\FileRepository::class);\n$fileObjects = $fileRepository->findByRelation('pages', 'media', $uid);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">where\u00a0<code>$uid<\/code>\u00a0is the id of some page. The return value is an array of\u00a0<code>\\TYPO3\\CMS\\Core\\Resource\\FileReference<\/code>\u00a0objects.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Listing files in a folder<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These would be the shortest steps to get the list of files in a given folder: get the Storage, get a Folder object for some path in that Storage (path relative to Storage root), finally retrieve the files.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$resourceFactory = \\TYPO3\\CMS\\Core\\Resource\\ResourceFactory::getInstance();\n$defaultStorage = $resourceFactory-&gt;getDefaultStorage();\n$folder = $defaultStorage-&gt;getFolder('\/some\/path\/in\/storage\/');\n$files = $defaultStorage-&gt;getFilesInFolder($folder);\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the frontend context In a frontend context, the&nbsp;\\TYPO3\\CMS\\Core\\DataHandling\\DataHandler&nbsp;class cannot be used and there is no specific API to create a File Reference. You are on your own. The simplest solution is to simply create a database entry into table \u201csys_file_reference\u201d by using directly the database connection class provided by TYPO3 CMS. A cleaner solution &hellip; <a href=\"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Getting referenced files in TYPO3<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Getting referenced files in TYPO3 - Hoja Mustaffa Abdul Latheef \u2013 Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting referenced files in TYPO3 - Hoja Mustaffa Abdul Latheef \u2013 Blog\" \/>\n<meta property=\"og:description\" content=\"In the frontend context In a frontend context, the&nbsp;TYPO3CMSCoreDataHandlingDataHandler&nbsp;class cannot be used and there is no specific API to create a File Reference. You are on your own. The simplest solution is to simply create a database entry into table \u201csys_file_reference\u201d by using directly the database connection class provided by TYPO3 CMS. A cleaner solution &hellip; Continue reading Getting referenced files in TYPO3\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/\" \/>\n<meta property=\"og:site_name\" content=\"Hoja Mustaffa Abdul Latheef \u2013 Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-11T00:16:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-11T00:16:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/hoja.in\/blog\/wp-content\/uploads\/2026\/10\/og-blog.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Hoja Mustaffa Abdul Latheef\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hojaonline\" \/>\n<meta name=\"twitter:site\" content=\"@hojaonline\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hoja Mustaffa Abdul Latheef\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/getting-referenced-files-in-typo3\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/getting-referenced-files-in-typo3\\\/\"},\"author\":{\"name\":\"Hoja Mustaffa Abdul Latheef\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#\\\/schema\\\/person\\\/e6fbd54c2061674d8ea3e7861d858c7b\"},\"headline\":\"Getting referenced files in TYPO3\",\"datePublished\":\"2021-05-11T00:16:01+00:00\",\"dateModified\":\"2021-05-11T00:16:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/getting-referenced-files-in-typo3\\\/\"},\"wordCount\":168,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#\\\/schema\\\/person\\\/e6fbd54c2061674d8ea3e7861d858c7b\"},\"articleSection\":[\"Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/hoja.in\\\/blog\\\/getting-referenced-files-in-typo3\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/getting-referenced-files-in-typo3\\\/\",\"url\":\"https:\\\/\\\/hoja.in\\\/blog\\\/getting-referenced-files-in-typo3\\\/\",\"name\":\"Getting referenced files in TYPO3 - Hoja Mustaffa Abdul Latheef \u2013 Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#website\"},\"datePublished\":\"2021-05-11T00:16:01+00:00\",\"dateModified\":\"2021-05-11T00:16:56+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/getting-referenced-files-in-typo3\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/hoja.in\\\/blog\\\/getting-referenced-files-in-typo3\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/getting-referenced-files-in-typo3\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/hoja.in\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Getting referenced files in TYPO3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/hoja.in\\\/blog\\\/\",\"name\":\"Hoja Mustaffa Abdul Latheef \u2013 Blog\",\"description\":\"Notes from daily work with TYPO3, PHP and AI-assisted engineering\",\"publisher\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#\\\/schema\\\/person\\\/e6fbd54c2061674d8ea3e7861d858c7b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/hoja.in\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#\\\/schema\\\/person\\\/e6fbd54c2061674d8ea3e7861d858c7b\",\"name\":\"Hoja Mustaffa Abdul Latheef\",\"logo\":{\"@id\":\"https:\\\/\\\/hoja.in\\\/blog\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"description\":\"Senior TYPO3 Developer at jweiland.net, TYPO3 CMS Certified Developer. I write about TYPO3 upgrades, extension development, PHP and AI-assisted engineering with Claude Code.\",\"sameAs\":[\"https:\\\/\\\/hoja.in\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Getting referenced files in TYPO3 - Hoja Mustaffa Abdul Latheef \u2013 Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/","og_locale":"en_US","og_type":"article","og_title":"Getting referenced files in TYPO3 - Hoja Mustaffa Abdul Latheef \u2013 Blog","og_description":"In the frontend context In a frontend context, the&nbsp;TYPO3CMSCoreDataHandlingDataHandler&nbsp;class cannot be used and there is no specific API to create a File Reference. You are on your own. The simplest solution is to simply create a database entry into table \u201csys_file_reference\u201d by using directly the database connection class provided by TYPO3 CMS. A cleaner solution &hellip; Continue reading Getting referenced files in TYPO3","og_url":"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/","og_site_name":"Hoja Mustaffa Abdul Latheef \u2013 Blog","article_published_time":"2021-05-11T00:16:01+00:00","article_modified_time":"2021-05-11T00:16:56+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/hoja.in\/blog\/wp-content\/uploads\/2026\/10\/og-blog.jpg","type":"image\/jpeg"}],"author":"Hoja Mustaffa Abdul Latheef","twitter_card":"summary_large_image","twitter_creator":"@hojaonline","twitter_site":"@hojaonline","twitter_misc":{"Written by":"Hoja Mustaffa Abdul Latheef","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/#article","isPartOf":{"@id":"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/"},"author":{"name":"Hoja Mustaffa Abdul Latheef","@id":"https:\/\/hoja.in\/blog\/#\/schema\/person\/e6fbd54c2061674d8ea3e7861d858c7b"},"headline":"Getting referenced files in TYPO3","datePublished":"2021-05-11T00:16:01+00:00","dateModified":"2021-05-11T00:16:56+00:00","mainEntityOfPage":{"@id":"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/"},"wordCount":168,"commentCount":0,"publisher":{"@id":"https:\/\/hoja.in\/blog\/#\/schema\/person\/e6fbd54c2061674d8ea3e7861d858c7b"},"articleSection":["Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/","url":"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/","name":"Getting referenced files in TYPO3 - Hoja Mustaffa Abdul Latheef \u2013 Blog","isPartOf":{"@id":"https:\/\/hoja.in\/blog\/#website"},"datePublished":"2021-05-11T00:16:01+00:00","dateModified":"2021-05-11T00:16:56+00:00","breadcrumb":{"@id":"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/hoja.in\/blog\/getting-referenced-files-in-typo3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hoja.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Getting referenced files in TYPO3"}]},{"@type":"WebSite","@id":"https:\/\/hoja.in\/blog\/#website","url":"https:\/\/hoja.in\/blog\/","name":"Hoja Mustaffa Abdul Latheef \u2013 Blog","description":"Notes from daily work with TYPO3, PHP and AI-assisted engineering","publisher":{"@id":"https:\/\/hoja.in\/blog\/#\/schema\/person\/e6fbd54c2061674d8ea3e7861d858c7b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hoja.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/hoja.in\/blog\/#\/schema\/person\/e6fbd54c2061674d8ea3e7861d858c7b","name":"Hoja Mustaffa Abdul Latheef","logo":{"@id":"https:\/\/hoja.in\/blog\/#\/schema\/person\/image\/"},"description":"Senior TYPO3 Developer at jweiland.net, TYPO3 CMS Certified Developer. I write about TYPO3 upgrades, extension development, PHP and AI-assisted engineering with Claude Code.","sameAs":["https:\/\/hoja.in\/"]}]}},"_links":{"self":[{"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":2,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/posts\/52\/revisions\/54"}],"wp:attachment":[{"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hoja.in\/blog\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}