TransWikia.com

How do I upload images to a specific folder (Component Backend)

Joomla Asked by Thiago Guimarães on July 21, 2020

I would like to know how I upload files to a specific folder through Joomla Administrator Panel (My Component Backend).

I know how to do it in the site part following along with this tutorial:

https://docs.joomla.org/Special:MyLanguage/J3.2:Developing_an_MVC_Component/Adding_an_Image#site.2Fcontrollers.2Fhelloworld.php

However I don’t know how to do the same thing in the backend part.

I have this in my controller file to edit and add a new image:

protected function allowAdd($data = array())
    {
        return parent::allowAdd($data);
    }


  protected function allowEdit($data = array(), $key = 'id')
    {
        $id = isset( $data[ $key ] ) ? $data[ $key ] : 0;
        if( !empty( $id ) )
        {
            return JFactory::getUser()->authorise( "core.edit", "com_gallery.image." . $id );
        }
    }

I could use my own code inside these functions but I think I won’t be able to check if the user has permissions to execute these actions. I’m not sure what JFactory::getUser()->authorise() is for but I think it authorises the user to perform actions when they have permission to do so.

So my question is:

Is there any way to use my own upload code and check whether the user has permissions to execute that action or not?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP