I've created a script.php which contains the following function:

protected function update400()

    JFolder::delete(JPATH_ROOT . '/media/mod_MYMODULE/js');

This function is then called inside Joomla's predefined preflight(). The function is getting, called, however upon installation, I get the following error:

JInstaller: :Install: File does not exist C:\wamp\www\tmp\install_53de639f7a0b6\400\media\js

At first I thought this was because I was calling update400() from the preflight() function, so I tried calling it from the postflight() function instead, however this did not make any difference.

What I'm trying to figure out, is why it's looking in the tmp folder when I have specifically defined the path.

Does anyone know why this is happening?

1 Answer 1


I use JPATH_SITE within the update method which works fine for me.

I wouldn't use the preflight at all. It would delete the files even if the update fails, which is likely not what you want. postflight is the most appropriate but you need to check if it's an install, update or discover there.

  • I've tried calling it from the postflight function again and using JPATH_SITE instead of JPATH_ROOT, as suggested, but it did not make any difference. I'm already checking to see if it's an update and the function is only called if it is
    – Lodder
    Commented Aug 3, 2014 at 17:54
  • I just put JFolder::delete(JPATH_ROOT . '/media/mod_MYMODULE/js'); into my components postflight method and it tried to delete the correct folder. No clue why it doesn't work for you, sorry :(
    – Bakual
    Commented Aug 3, 2014 at 19:22
  • Hmm odd. I will some some more testing then. I'll be sure to test on a live host just in case it's something to do with my localhost dev environment
    – Lodder
    Commented Aug 4, 2014 at 0:31
  • I've done some more testing. Tried using _ROOT, _SITE and _BASE but none work. Also tried in Joomla 2.5 and 3.2 but the same issue occurs. Would you be able to provide your working example? This is assuming the folder/file to delete is in Joomla's media folder. You don't think this is a security measure that was implemented into Joomla to prevent any core files being deleted do you?
    – Lodder
    Commented Aug 6, 2014 at 19:53
  • 1
    JPATH_ROOT should always be the root directory, regardless of application. JPATH_BASE would be dependant on current application (site or administrator). JPATH_SITE is always for the site application. See docs.joomla.org/Constants
    – Bakual
    Commented Aug 7, 2014 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.