{"id":22802515,"url":"https://github.com/mindscreen/t3ext-fal_upload","last_synced_at":"2025-06-25T23:32:01.248Z","repository":{"id":57017167,"uuid":"143406770","full_name":"mindscreen/t3ext-fal_upload","owner":"mindscreen","description":null,"archived":false,"fork":false,"pushed_at":"2019-10-11T15:00:49.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T21:18:12.183Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mindscreen.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-03T09:20:06.000Z","updated_at":"2019-10-11T15:00:50.000Z","dependencies_parsed_at":"2022-08-22T09:40:40.213Z","dependency_job_id":null,"html_url":"https://github.com/mindscreen/t3ext-fal_upload","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mindscreen/t3ext-fal_upload","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mindscreen%2Ft3ext-fal_upload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mindscreen%2Ft3ext-fal_upload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mindscreen%2Ft3ext-fal_upload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mindscreen%2Ft3ext-fal_upload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mindscreen","download_url":"https://codeload.github.com/mindscreen/t3ext-fal_upload/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mindscreen%2Ft3ext-fal_upload/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261972867,"owners_count":23238539,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-12T09:06:19.818Z","updated_at":"2025-06-25T23:32:01.199Z","avatar_url":"https://github.com/mindscreen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n================================================\nFile Upload using Extbase and FAL in TYPO3 \u003e 6.2\n================================================\n\n.. post::\n   :tags: TYPO3, Extbase\n\n\n\n\n.. highlight:: php\n.. default-role:: code\n\n\n:Project:\n      TYPO3 CMS extension ext:fal_upload for TYPO3 \u003e= 6.2.4\n\n:Author:\n      `Michael Telgkamp \u003cmichael.telgkamp@mindscreen.de\u003e`__\n\n:Repository:\n      At Github `mindscreen/t3ext-fal_upload \u003chttps://github.com/mindscreen/t3ext-fal_upload\u003e`__\n\n:Credit:\n      - `Helmut Hummel \u003chelmut.hummel@typo3.org\u003e`__ - for his extension `upload_example \u003chttps://github.com/helhum/upload_example\u003e`__ as inspiration\n\n\n**Overview:**\n\n.. contents::\n   :local:\n   :depth: 3\n   :backlinks: none\n\n\n\nWhat does it do?\n================\n\nThis is an extension simplifying the addition of file upload functionality in other extensions.\n\n\nHow does it work?\n=================\n\n- The heart of the extension is the UploadedFileReferenceConverter\n- an extended FileReference model is needed\n- an extended ObjectStorageConverter is needed\n- an extended UploadViewHelper is needed\n\n\nWhat needs to be done?\n======================\n\nTypeConverter\n-------------\n\nWe want to have a custom TypeConverter to:\n\n- evaluate the file upload array\n- move the uploaded file to a FAL storage using the FAL API\n- and have the result persisted in the database using the Extbase persistence.\n\n\nError handling\n--------------\n\nWe don't want to just throw exceptions but use the TypeConverter API\nto return useful error messages to the user.\n\n\nConfigurability\n---------------\n\nThings should be configurable, especially the TypeConverter. It needs to know\nabout\n\n1. the folder to upload to\n2. what to do in case of a name conflict for the uploaded file\n3. the allowed file extensions\n4. how to deal with an already attached resource.\n\nThe actual configuration is done through by PropertyMappingConfiguration.\n\nSome configuration options::\n\n   \u003c?php\n   class UploadedFileReferenceConverter extends \\TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\AbstractTypeConverter {\n\n      /**\n       * Folder where the file upload should go to\n       * (including storage).\n       */\n      const CONFIGURATION_UPLOAD_FOLDER = 1;\n\n      /**\n       * How to handle an upload when the name\n       * of the uploaded file conflicts.\n       */\n      const CONFIGURATION_UPLOAD_CONFLICT_MODE = 2;\n\n      /**\n       * Whether to replace an already present resource.\n       * Useful for \"maxitems = 1\" fields and properties\n       * with no ObjectStorage annotation.\n       */\n      const CONFIGURATION_ALLOWED_FILE_EXTENSIONS = 4;\n   }\n\n\nHandle validation errors and already attached resources\n-------------------------------------------------------\n\nDifferent cases need to be handled.\n\nCase: A file is already attached\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n- When editing an entity that has already an image attached to it,\n  through a previous upload for example, saving the entity without\n  re-uploading a file should keep the attached resource.\n\nKnowing about an already attached resource is not only in the domain\nof the TypeConverter. Therefore the UploadViewHelper assigns such values\nto a hidden input and protects it by an hash value (hmac).\n\nAdditionally the viewhhelper accept child nodes and provides an object \"resource\".\nThis means that you can render the attached resource if you like to. In this\nexample a preview of the image is shown:\n\n.. code-block:: html\n\n   \u003ch:form.upload property=\"image\" \u003e\n      \u003cf:if condition=\"{resource}\"\u003e\n         \u003cf:image image=\"{resource}\" alt=\"\" width=\"50\"/\u003e\n      \u003c/f:if\u003e\n   \u003c/h:form.upload\u003e\u003cbr /\u003e\n\n\nCase: Upload succeeds, validation fails\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nIn this case the file upload succeeds but due to validation errors in some other\nfields the whole form isn't accepted. This also means it isn't persisted yet but we\nnevertheless want to keep the uploaded file as a resource as we don't want to upload it again.\n\nSecurity\n--------\n\nTo make file upload secure the TypeConverter needs at least needs to care about these two issues:\n\n1. Deny upload of PHP files! ::\n\n      \u003c?php\n      if (!GeneralUtility::verifyFilenameAgainstDenyPattern($uploadInfo['name'])) {\n         throw new TypeConverterException('Uploading files with PHP file extensions is not allowed!', 1399312430);\n      }\n\n   It cannot be stressed enough how important these three lines of code are!\n\n   .. important::\n\n      - These lines are mandatory and NOT optional.\n      - These lines are independent from the configurable allowed file extensions.\n\n\n\nInstall\n=======\n\n1. Get from Github, install as extension\n2. Create folder ./fileadmin/content\n3. No extra TypoScript needs to be included\n4. Create an extension and use the classes provided by the plugin\n5. Start playing\n\n\nAdaptation\n==========\n\n- Look into the controller to get an idea about how how to configure the type converter.\n- Look into the TCA to see how to properly set the match_fields so that Extbase Persistence\n  does the right thing.\n- ...\n\n\nContribute\n==========\n\n- `Send pull requests to the repository. \u003chttps://github.com/mindscreen/fal_upload\u003e`__\n- `Use the issue tracker for feedback and discussions. \u003chttps://github.com/mindscreen/fal_upload/issues\u003e`__\n\nEnjoy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmindscreen%2Ft3ext-fal_upload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmindscreen%2Ft3ext-fal_upload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmindscreen%2Ft3ext-fal_upload/lists"}