Typo3 file upload problems

Total
0
Shares

I’ve encountered some problems with the TYPO3 backend’s way of handling files during some work on a picture upload extension. Specifically TYPO3 moves all files you upload to the folder designed as uploadfolder in the field’s TCA setup.

But i do not want this. I want him to leave the files where i put them. Unfortunately replacing the uploadfolder value with an empty string made TYPO3 to store the whole path to the file, something like: var/www/vhosts/example.com/…

This is not good either. I want him to store the relative filepath to the fileadmin folder. I’ve discovered this issue on the TYPO3 bugtracker which provided me the solution. There is also a nice little extension called eM References that enables you to change this behavior.

After you installed the extension practically you need to change in TCA the internal type of the field from ‘file’ to ‘file_references’ and skip the uploadfolder setting entirely. This way the file will be uploaded where you need it and a relative path (a filereference) is stored in the database. No more copying of the file made by TYPO3 in places you didn’t want to.

To ease your work, here is an example configuration for a TCA entry of file_references type

"tx_myext_filereferences" => Array (
        "exclude" => 1,
        "label" => "LLL:EXT:myext/locallang_db.xml:tt_content.tx_myext_filereferences",
        "config" => Array (
            "type" => "group",
            "internal_type" => "file_references",
            "allowed" => $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["imagefile_ext"],
            "max_size" => 1000,
            "show_thumbs" => 1,
            "size" => 3,
            "minitems" => 0,
            "maxitems" => 10,
        )

),

1 comment
Leave a Reply to tomitzel Cancel reply

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

You May Also Like