I am creating a Joomla package that will install some plugins and some image files together. I want to copy the images from the package to the Joomla site using an installer script. How do I find the name of the temporary install directory in order to copy the files?

My pkg_foo.zip has the following directory structure.


And I have the following in script.php:


class pkg_fooInstallerScript
    function install($parent) {
            JFile::move( TEMPORARY_DIRECTORY . '/image.png', JPATH_ROOT . 'images/image.png';


How do I find the path to the temporary install directory?

  • 1
    I would suggest you install the images as part of the plugin, then copy from there after the installation, using the postflight() function
    – Lodder
    Feb 13 '17 at 11:00
  • I would prefer to copy from the temporary install directory. The reason being that the plugins I am installing are 3rd party. I don't want to edit the archives because any changes I make will be over-written if I update. Creating and installing a plugin for the sole purpose of holding the images before moving them doesn't seem correct either.The correct solution would be to copy the files from the package to the correct destination on installation.
    – Codewise
    Feb 13 '17 at 11:10
  • If I'm not mistaken, you can't get the temp directory during the install process. I think you misunderstood what I meant though, so I'll add an answer below
    – Lodder
    Feb 13 '17 at 11:15

You can use the postflight() function to move the images after the install() function has been executed and completed, like so:

class pkg_fooInstallerScript
    protected $extension = 'plg_myplugin';

    public function install($parent) 
        // Do whatever you need to do when installing

    public function postflight($type, $parent) 
        // Only run the code if we're installing, not updating.
        if (strtolower($type) === 'install')
            $imagePath = JPATH_SITE . '/plugins/' . $this->extension . '/images/image.png';
            $newPath   = JPATH_SITE . '/images/image.png';

            JFile::move($imagePath, $newPath;

To get the name of the temporary install directory from within the installer script - script.php, use this:

function install($parent)
    $temp_dir = $parent->getParent()->getPath('source');

and if you need it during updates, then place it in the update method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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