Question

I made file upload according to http://docs.typo3.org/flow/TYPO3FlowDocumentation/TheDefinitiveGuide/PartIII/ResourceManagement.html

I have this error: Invalid type encountered: '\TYPO3\Flow\Resource\Resource'

Code

Controler:

class Tx_PromConf_Controller_RegistrationController extends Tx_Extbase_MVC_Controller_ActionController { 
/**
    * Imports a passport
    *
    * @param Tx_PromConf_Domain_Model_Passport $passport The new passport
    * @return void
    */
    public function passportUploadAction(Tx_PromConf_Domain_Model_Passport $passport) {
        $this->passportRepository->add($passport);
        $this->forward('index');
    }
}

Model

class  Tx_PromConf_Domain_Model_Passport extends Tx_Extbase_DomainObject_AbstractEntity {

    /**
     * @var string
     */
    protected $title;

    /**
     * @var \TYPO3\Flow\Resource\Resource
     */
    protected $originalResource;

    /**
     * @param string $title
     * @return void
     */
    public function setTitle($title) {
        $this->title = $title;
    }

    /**
     * @return string
     */
    public function getTitle() {
        return $this->title;
    }

    /**
     * @param \TYPO3\Flow\Resource\Resource $originalResource
     * @return void
     */
    public function setOriginalResource(\TYPO3\Flow\Resource\Resource $originalResource) {
        $this->originalResource = $originalResource;
    }

    /**
     * @return \TYPO3\Flow\Resource\Resource
     */
    public function getOriginalResource() {
        return $this->originalResource;
    }

    /**
     * __construct
     *
     * @return void
     */
    public function __construct() {
        //Do not remove the next line: It would break the functionality
        $this->initStorageObjects();
        $this->setTitle('PassportScan');
    }

    /**
     * Initializes all Tx_Extbase_Persistence_ObjectStorage properties.
     *
     * @return void
     */
    protected function initStorageObjects() {

    }
}

Form

<f:form action="passportUpload" controller="Registration" enctype="multipart/form-data" 
            object="{passport}" objectName="passport">
        <br />
        <div>
            <f:translate key="tx_promconf_passport_upload.sentense" />
        </div>
        <br />
        <div class="max-size">
            <f:form.upload class="btn" name="originalResource" />
        </div>
        <br />
        <br />
        <div class="max-size">
            <f:form.submit name="mySubmit" class="btn btn-l" value="<f:translate key='tx_promconf_passport_upload.ok' />" />
            <input type="reset" class="btn btn-r" value="<f:translate key='tx_promconf_passport_upload.cancel' />" />    
        </div>
    </f:form>
Was it helpful?

Solution

In case you are using TYPO3 CMS:
You will not find the class TYPO3\Flow\Resource\Resource there.

Therefore you are bound to Extbase classes. If you are using TYPO3 6.x, you might want to look either in the Extbase namespace or somewhere here: \TYPO3\CMS\Core\Resource\ResourceInterface.
But most probably, the easiest way is to look for another tutorial on file uploads with Extbase.

If you're developing a standalone FLOW application, I don't have a precise answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top