Question

I've been following the documentation here to add a (improved) file upload section to an existing component.

The link in the example above to the controller/model to then process the upload is formed through the post params:

    post_params: 
    {
            "option" : "com_mycomponent",
            "controller" : "mycontroller",
            "task" : "mytask",
            "id" : "'.$myItemObject->id.'",
            "'.$session->getName().'" : "'.$session->getId().'",
            "format" : "raw"
    }, 

My problem is the upload isn't working using the new controller methods introduced in Joomla 2.5:

// Get an instance of the controller prefixed by the component
$controller = JController::getInstance('mycomponent');

// Perform the Request task
$controller->execute(JRequest::getCmd('task'));

// Redirect if set by the controller
$controller->redirect();

This worked (and indeed on Joomla 2.5) does work absolutely fine on the old 1.5 method for loading a controller:

// Create the controller
$classname  = 'mycomponentController'.$controller;
$controller = new $classname( );

// Perform the Request task
$controller->execute( JRequest::getVar('task'));

// Redirect if set by the controller
$controller->redirect();

Whilst this latter method is Joomla 2.5 compatible, unfortunately the component I wish to integrate this with uses the newer method and I'd rather not change this so I can keep updating the component as required without having to change this every time. Also if I did change it I'm guessing I may loose the existing features.

Basically I want to know how to set up the post params so that the new controller method is called correctly!


EDIT

I have since tried using a post param configuration of:

post_params: 
{
    "option" : "com_mycomponent",
    "task" : "mycontroller.mytask",
    "id" : "'.$myItemObject->id.'",
    "'.$session->getName().'" : "'.$session->getId().'",
    "format" : "raw"
}, 

I an attempt to emulate a link along the lines of index.php?option=com_mycomponent&task=mycontroller.mytask etc. But this still doesn't work either

Was it helpful?

Solution

You need to define below variable in index.php

define('_JREQUEST_NO_CLEAN', 1);

I was looking for the cause and I found this- http://docs.joomla.org/Framework_Compatibility

Note- If this does not work remove "format" : "raw".

Let me know if it does not work.

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