AnswerBun.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!

Related Questions

Getting Category’s custom fields in a blog view

1  Asked on September 5, 2021 by semaphore

   

How to post checkout data to component using Ajax?

1  Asked on September 5, 2021 by askerman

   

Display specific Joomla user groups

1  Asked on September 5, 2021 by niaziblog

   

how to get value for search in joomla module

1  Asked on September 5, 2021 by rhea-lorraine

   

Joomla installation on localhost using WAMP does not start

1  Asked on September 5, 2021 by bilal-kabeer-butt

 

Jquery script loaded on every page

1  Asked on September 5, 2021 by gag

   

category links don’t work

1  Asked on September 5, 2021 by giovanni-de-maria

         

Joomla 3.9 Child Sub Menu Not Showing

1  Asked on September 5, 2021 by ta1982

         

Trying to connect to an external ODBC data source

1  Asked on September 5, 2021 by irata

   

Can’t get a task to work from CLI

0  Asked on September 5, 2021 by tc0072

 

Ask a Question

Get help from others!

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