• Fabrik4.5.3 for J!5.3.0 and J!4.2+is out

    You must update from Fabrik4.5.1 if you are running Joomla!5.3.0

    See Announcements

Solved Download list plugin

dimoss

Well-Known Member
Hi,

i saw in WiKi the download list plugin
https://fabrikar.com/forums/index.php?wiki/download-list-plugin/

I never used it in the past so I don't know if it's working or not. I know it's not in F4.x package but i wonder if there any possibility to have this in the future?

If not, would it be possible to be done with a php list plugin or another way?

I am interested to download uploaded, via fileupload element, files of selected rows in a .zip file.

Thanks.
 
Do you have a Fabrik4.0 somewhere?
It was in there, you could extract the package and try to install this plugin's zip.
I don't know if it's working but it can be selected in a list.
 
Do you have a Fabrik4.0 somewhere?
It was in there, you could extract the package and try to install this plugin's zip.
I don't know if it's working but it can be selected in a list.
Thanks for the prompt reply @troester
Unfortunately I don't have F4.0 so i cannot find this plugin.
I was wondering if could be possible make it through PHP list plugin selecting the rows getting the list of absolute paths and then use a kind of scripts to download the files in zip format.
 
Hi @troester

Thanks for the file. I installed and used it in a list where i have fileupload elements and worked ok.
It downloaded the files of the selected rows in a ZIP format.
Below the plugin settings I used:

1733838798992.png


where file element is the fileupload element which holds the path to the file.

With the help of ChatGPT I tried another way using a PHP list plugin and it worked too. Below i share the code for anyone in the forum interested in alternatives:


PHP:
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;

$db = Factory::getContainer()->get('DatabaseDriver');
$app = Factory::getApplication();

$ids = $app->getInput()->get('ids', array(), 'array');

$baseUrl = Uri::root(); // Joomla base URL

$filePaths = [];
$photoFolder = null;

foreach ($ids as $myid) {
    $row = $model->getRow($myid);
    if (!$row) {
        continue;
    }
    $photo = $row->vw_overview___Photo_raw ?? '';

    if (empty($photo)) {
        continue;
    }

    $photoUrl = $baseUrl . ltrim($photo, '/');

    if (is_null($photoFolder)) {
        $photoFolder = dirname(JPATH_SITE . $photo) . '/';
    }

    $filePaths[] = $photo;
}

if (is_null($photoFolder) || empty($filePaths)) {
    echo 'No valid photos found to create ZIP.';
    exit;
}

$zipFileName = $photoFolder . 'photos.zip';
$zip = new ZipArchive();
if ($zip->open($zipFileName, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== true) {
    echo 'Failed to create ZIP file.';
    var_dump($zipFileName);
    exit;
}

foreach ($filePaths as $filePath) {
    $absolutePath = JPATH_SITE . $filePath;
    if (file_exists($absolutePath)) {
        $zip->addFile($absolutePath, basename($absolutePath));
    }
}

$zip->close();

header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="photos.zip"');
header('Content-Length: ' . filesize($zipFileName));
readfile($zipFileName);

unlink($zipFileName);

exit;
 
Back
Top