3

I'm building a simple extension based on extbase / fluid which has an upload form in a frontend plugin. It was working in 6.0.4, but now I get the following exception when I try to upload a file:

#1297759968: Exception while property mapping at property path "fichier":No converter found which can be used to convert from "array" to "string".

The problem seems to be related to the fact that the web request receives an array for the uploaded file, but the model stores it as a string. How can I get rid of this exception? How should I handle file upload in extbase?


The extension was started using Extension Builder. fichier is a string property in the Model, containing the name of the uploaded file (located into uploads/tx_myext/). The template for the plugin contains an upload field build from a form.upload ViewHelper. On TYPO3 6.0.4, when I submit the form, I receive an object as argument to the createAction function. From that object, I call getFichier that returns me the file array of the uploaded file. Then, I can extract the original file name, copy the temp file to the right location, and set the value of the fichier property using the original file name.

Now, in TYPO3 6.1.0, I get the above exception before entering the createAction function. My guest is that PropertyMapper is trying to translate the file array to a string to match the type of fichier property.

What I don't know is was the way it worked before was a bug, or is it the way it works now that is the bug. And if it really works the way it is intended to do, how should I be able to handle file upload in an extbase extension?

2
  • you need to give more details
    – biesior
    Commented May 6, 2013 at 21:13
  • I added some details. Is it clearer now? Commented May 7, 2013 at 1:33

1 Answer 1

7
 /**
 * initialize actions
 */
public function initializeAction() {
    if ($this->arguments->hasArgument('myModel')) {
        $this->arguments->getArgument('myModel')->getPropertyMappingConfiguration()->setTargetTypeForSubProperty('upload', 'array');
    }
}

http://www.typo3lexikon.de/typo3-tutorials/extensions/extbase/property-mapper.html

1
  • 5
    It probably worth pointing out that initializeAction is called for each action of the Controler, and that myModel refers to the name of the variable given to the createAction() function. Commented May 7, 2013 at 15:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.