File resources

TYPO3 Flow Resource Management

The documentation [1] on flow.typo3.org about the resource management is already finished. There are some nice examples and the resource management is working good in Flow 1.x

Anyway, when I played around with it some time ago I missed one point, so I try to explain it in a small example. I wanted to upload some csv files and I wanted to work with the data. So this example shows how to upload a file and use the object later on.

Create the upload form

Nothing new here I guess. We just use the Fluid form view helper for creating our form and we set the type of our field to f:form.upload and we are done. Now you can see the input button on your page to select a file you want to upload.

Create the fileUpload action

First part is almost the same like in the example on flow.typo3.org. What took me some time is to find out how I can access the file to work with the data in the file.

It is really easy and I can’t remember what took me so long. What you have to do is to get the uri of the resource object. As soon as you have the resource uri, you can use it like a file name and do, like in my example, an fopen on the file and get the content.

 

Create a download link

 

 

3 thoughts on “File resources

  1. mario

    Hi
    thanks for the hints.
    Why is array $fileUpload?
    I try something veru similar, and get “Required argument “fileUpload” is not set.”. Any further hint?
    best m.

    Reply
    1. Thomas Layh Post author

      Hi Mario,

      sorry for the late response, I was on vacation. The array $fileUpload is the name of the form field where you can add the files. It will be assigned to the action automatically. So whatever you set as argument, you have to name the formElement with the same name.

      Hope this helps.
      Greetings,
      Thomas

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *