upload_example icon indicating copy to clipboard operation
upload_example copied to clipboard

Upload new image in update action

Open bednee opened this issue 8 years ago • 6 comments

I'm trying to edit persisted record with a single image. The image was uploaded via FE. Unfortunately this is not working. A new image is uploaded but it's added to the relation instead of replacing it. The model has property of FileReference type, not ObjectStorage, as it should store only single image. However, when looking at the record in BE, I see 2 relations. Any idea what I may be doing wrong or how to fix it?

bednee avatar Feb 26 '17 19:02 bednee

Same with my implementation, do you have any solutions?

beilm avatar Jun 19 '17 07:06 beilm

I have the same issuse but it seems more related to extbase. The converter works fine, you get the filereference but extbase don't switch the files.

Xippo avatar Jul 03 '17 15:07 Xippo

I would recommend to always use an object storage, which will then lead to the desired behavior.

helhum avatar Jul 03 '17 16:07 helhum

Hello, I have the same problem. I uploaded a new image and in database the sys_file_reference is changed but in the frontend output there es used the old one. Why?

akzeitlos avatar Jan 31 '18 20:01 akzeitlos

I encountered the same problem while running it in TYPO 8.7.19 and found out, that the problem happened during the conversion of the already uploaded resource inside the UploadViewHelper. While in TYPO 7.6, $this->getValueAttribute() returns the ID of the existing upload as a string, it returns an integer in TYPO 8. This leads to TYPO not setting it as the UID of the converted FileReference, thinking there is no attached resource AND creating a second relation instead of replacing it with the newly uploaded file.

Long Story Short: Casting $resource to string before converting it did the trick for me. Maybe it helps some of you.

protected function getUploadedResource()
{
    // ...
    return $this->propertyMapper->convert((string)$resource, 'TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference');
}

FearFreddy avatar Dec 04 '18 22:12 FearFreddy

I encountered the same problem while running it in TYPO 8.7.19 and found out, that the problem happened during the conversion of the already uploaded resource inside the UploadViewHelper. While in TYPO 7.6, $this->getValueAttribute() returns the ID of the existing upload as a string, it returns an integer in TYPO 8. This leads to TYPO not setting it as the UID of the converted FileReference, thinking there is no attached resource AND creating a second relation instead of replacing it with the newly uploaded file.

Long Story Short: Casting $resource to string before converting it did the trick for me. Maybe it helps some of you.

protected function getUploadedResource()
{
    // ...
    return $this->propertyMapper->convert((string)$resource, 'TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference');
}

This fixed the exact same issue for me - thank you very much.

tomwarwick avatar Jan 31 '19 15:01 tomwarwick