From Joomla! Documentation

< API16:JInstallerHelper
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.


Unpacks a file and verifies it as a Joomla element package Supports .gz .tar .tar.gz and .zip

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >


Parameter Name Default Value Description
$p_filename $p_filename The uploaded package filename or install directory


Array Two elements - extractdir and packagefile

Defined in



jimport( 'joomla.installer.helper' );

Source Body

function unpack($p_filename)
        // Path to the archive
        $archivename = $p_filename;
        // Temporary folder to extract the archive into
        $tmpdir = uniqid('install_');
        // Clean the paths to use for archive extraction
        $extractdir = JPath::clean(dirname($p_filename).DS.$tmpdir);
        $archivename = JPath::clean($archivename);
        // do the unpacking of the archive
        $result = JArchive::extract($archivename, $extractdir);
        if ($result === false) {
                return false;
         * Lets set the extraction directory and package file in the result array so we can
         * cleanup everything properly later on.
        $retval['extractdir'] = $extractdir;
        $retval['packagefile'] = $archivename;
         * Try to find the correct install directory.  In case the package is inside a
         * subdirectory detect this and set the install directory to the correct path.
         * List all the items in the installation directory.  If there is only one, and
         * it is a folder, then we will set that folder to be the installation folder.
        $dirList = array_merge(JFolder::files($extractdir, ''), JFolder::folders($extractdir, ''));
        if (count($dirList) == 1)
                if (JFolder::exists($extractdir.DS.$dirList[0]))
                        $extractdir = JPath::clean($extractdir.DS.$dirList[0]);
         * We have found the install directory so lets set it and then move on
         * to detecting the extension type.
        $retval['dir'] = $extractdir;
         * Get the extension type and return the directory/type array on success or
         * false on fail.
        if ($retval['type'] = JInstallerHelper::detectType($extractdir)) {
                return $retval;
        else {
                return false;

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >


<CodeExamplesForm />