Problem with file upload TCA after upgrading to TYPO3 10 - typo3

On typo3v9 i had working file upload field with this TCA configuration:
'image' => [
'exclude' => 0,
'label' => 'image upload',
'config' => [
'type' => 'group',
'internal_type' => 'db',
'uploadfolder' => 'uploads/folder',
'show_thumbs' => 1,
'size' => 5,
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'disallowed' => '',
],
],
i get this result:
but after migration to typo3v10 it does not work properly and give this result:
Someone have working solution for single file upload field?

I guess you mean internal_type=file ? That's deprecated. Here an example for image upload. However you can allow other types here too, I am sure you can find more info on that.
'photos' => [
'exclude' => true,
'label' => 'LLL:EXT:xxx/Resources/Private/Language/locallang_db.xlf:tx_xxx_domain_model_activity.photos',
'config' =>
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'photos',
[
'appearance' => [
'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference'
],
'foreign_types' => [
'0' => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
]
],
'maxitems' => 30
],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
],

Related

How to create a TCA field for uploading a PDF file to SQL `mediumblob` in TYPO3 10.4

I am trying to find solution, that will allow user to upload PDF file via TCA. Uploaded file musn't create relation with sys_file_reference.
My current code in TCA:
'pdf_data' => [
'exclude' => true,
'label' => 'PDF file',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'pdf_file',
[
'appearance' => [
'createNewRelationLinkTitle' => 'Add PDF file',
],
'maxitems' => 1,
'minitems' => 0,
'overrideChildTca' => [
'types' => [
'0' => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
],
],
'filter' => [
'0' => [
'parameters' => [
'allowedFileExtensions' => 'pdf'
]
]
],
'default' => null,
],
'pdf'
),
]
],
Although Thomas already stated, that it is very uncommon and you really need a good reason to store PDF files in a database, you could still try to provide your own form engine rendering via TCA column type user
https://docs.typo3.org/m/typo3/reference-tca/10.4/en-us/ColumnsConfig/Type/User.html
Just make sure to provide a render type, that will return basic information about the stored data, so that BE users will get a convenient user interface to deal with the files.
Additionally you might want to deal with the data while it gets stored, so providing methods for the DataHandler would be necessary too.
https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Typo3CoreEngine/Introduction/Index.html

TYPO3: add maxitems = 1 to an image selection for a backend module

I use the following code to make an image selection available in the backend:
(TYPO3 docs - inline - File Abstraction Layer)
'image' => [
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.images',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'image',
[
'appearance' => [
'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference'
],
// custom configuration for displaying fields in the overlay/reference table
// to use the image overlay palette instead of the basic overlay palette
'overrideChildTca' => [
'types' => [
'0' => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
],
],
],
],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
],
I want to limit the selection to 1 item which should be:
TYPO3 dosc - maxitems option
image => [
'config' => [
'maxitems' => 1,
],
],
I cannot find how to add that ... all I tried gives errors
Sometimes, you just have to find the matching part of documentation...
File abstraction layer (FAL)
The API call is \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(). The first argument is the name of the current field, the second argument is an override configuration array, (...)
So it should do with overriding a part of the generated configuration by:
'image' => [
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.images',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'image',
[
'maxitems' => 1
]
)
]

TYPO3 Delete FileReference as non admin

I can't figure out which setting I have to activate to allow non-admin users to delete file references in the backend.
As admin I have that little trash icon which is missing when logged in as non-admin user.
I set every single flag to allow data manipulation in the backend users module but nothing worked so far. The only option is to give the user admin privileges. What do I miss?
Edit:
I am on TYPO3 10.4
Edit:
TCA for field:
'image' => [
'exclude' => true,
'label' => 'Image',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'image',
[
'appearance' => [
'createNewRelationLinkTitle' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference'
],
'foreign_types' => [
\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
'showitem' => '
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
--palette--;;filePalette'
]
],
'foreign_match_fields' => [
'fieldname' => 'image',
'tablenames' => 'tx_association_domain_model_association',
'table_local' => 'sys_file',
],
'maxitems' => 1,
'minitems' => 0
],
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
),
],

Where to influence in which languages an extbase record can be translated?

In a custom built TYPO3 extension, records are only available in language -1 in the backend. That was specified as such, but should now be changed so records can be translated.
Something is missing. I thought this would be in TCA, but the definitions look quite normal:
'columns' => [
'sys_language_uid' => [
'exclude' => true,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'items' => [
[
'LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages',
-1,
'flags-multiple'
]
],
'default' => 0,
],
],
'l10n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0',
'exclude' => true,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['', 0],
],
'foreign_table' => 'tx_myext_domain_model_item',
'foreign_table_where' => 'AND tx_myext_domain_model_item.pid=###CURRENT_PID### AND tx_myext_domain_model_item.sys_language_uid IN (-1,0)',
],
],
Also, when I change TCA, for example change config as such:
'config' => array(
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'sys_language',
'foreign_table_where' => 'ORDER BY sys_language.title',
'items' => array(
array('LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1),
array('LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0)
),
),
It's still the same: only language -1 (ALL) is selectable.
Of course, the sysfolder those records are on is translated in multiple languages. Also, the columns for sys_language_uid, l10n_parent and l10n_diffsource are present in the database.
Are the other languages maybe disabled somewhere? Where else could I look?
Or which element could be missing else to make records translateable?
Thanks for any hint.

ZF 2.4 File Validator Required False Doesn't Work

Today I updated to ZF 2.4 to use float validator but unfortunately i realized that my file upload form field gives unexpected error messages.
Here is my form object
$this->add([
'name' => 'profileimage',
'type' => '\Zend\Form\Element\File',
'attributes' => [
'id' => 'profileimage',
'class' => 'styled',
],
]
);
And Here is my validator
$inputFilter->add([
'name' => 'profileimage',
'required' => false,
'allow_empty' => true,
'priority' => 300,
'filters' => [
['name' => 'StripTags'],
['name' => 'StringTrim'],
],
'validators' => [
[
'name' => '\Zend\Validator\File\IsImage',
],
[
'name' => '\Zend\Validator\File\UploadFile',
],
[
'name' => '\Zend\Validator\File\ImageSize',
'options' => [
'minWidth' => 300,
'minHeight' => 300,
]
],
[
'name' => '\Zend\Validator\File\Size',
'options' => [
'max' => '20MB',
]
],
]
]);
As you see the image upload field is not required and may be empty. But in my form I get these errors:
array (size=1)
'profileimage' =>
array (size=4)
'fileIsImageNotReadable' => string 'File is not readable or does not exist' (length=38)
'fileUploadFileErrorNoFile' => string 'File was not uploaded' (length=21)
'fileImageSizeNotReadable' => string 'File is not readable or does not exist' (length=38)
'fileSizeNotFound' => string 'File is not readable or does not exist' (length=38)
How can I handle this issue? I need to this field to be optional.
change your filter
$inputFilter->add([
'name' => 'profileimage',
'type' => '\Zend\InputFilter\FileInput',
'required' => false,
'allow_empty' => true,
'priority' => 300,
'filters' => [
['name' => 'StripTags'],
['name' => 'StringTrim'],
],
'validators' => [
[
'name' => '\Zend\Validator\File\IsImage',
],
[
'name' => '\Zend\Validator\File\UploadFile',
],
[
'name' => '\Zend\Validator\File\ImageSize',
'options' => [
'minWidth' => 300,
'minHeight' => 300,
]
],
[
'name' => '\Zend\Validator\File\Size',
'options' => [
'max' => '20MB',
]
],
]
]);
read about it here: http://framework.zend.com/manual/current/en/modules/zend.input-filter.file-input.html