'What goes in the upload configuration (path) to save an image in the fileadmin user_upload folder in typo3 10?
I named my image file upload as "myImage" an want to ask what goes in in the path in the code below to upload an image in my user_upload folder in a typo3 10 backend extension. The extension which I want to create as: in the upload example extension
{namespace h=Vendor\ExtensionName\ViewHelpers}
<h:form.upload property="myImage">
<f:if condition="{resource}">
<f:image image="{resource}" alt="" width="50"/>
</f:if>
</h:form.upload>
protected function setTypeConverterConfigurationForImageUpload($argumentName)
{
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)
->registerImplementation(
\TYPO3\CMS\Extbase\Domain\Model\FileReference::class,
\Vendor\ExtensionName\Domain\Model\FileReference::class
);
$uploadConfiguration = [
UploadedFileReferenceConverter::CONFIGURATION_ALLOWED_FILE_EXTENSIONS => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
UploadedFileReferenceConverter::CONFIGURATION_UPLOAD_FOLDER => '1:/fileadmin/myfolder/', // here is the point of my question
];
/** @var PropertyMappingConfiguration $newExampleConfiguration */
$newExampleConfiguration = $this->arguments[$argumentName]->getPropertyMappingConfiguration();
$newExampleConfiguration->forProperty('myImage')
->setTypeConverterOptions(
UploadedFileReferenceConverter::class,
$uploadConfiguration
);
}
Solution 1:[1]
CONFIGURATION_UPLOAD_FOLDER is a combined identifier. Combined identifies have the syntax:
< storage uid >: < file identifier >
Normally, you have the default storage (fileadmin) with UID 1. The uploadfolder may be in this storage, so it has to be prefixed with "1:". After the storage UID, the path in this storage follows.
In your case of target folder /fileadmin/myfolder/ the first part will automatically be added by the defined storage. The path in this storage is myfolder.
So, you should set your CONFIGURATION_UPLOAD_FOLDER
1:/myfolder
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Julian Hofmann |
