Moving uncompressed bulk data loads between client(APP) and server is not really realistic or optimal. Selecting multiple BLOB images from a MySQL database that is. How can I ZIP the server folder of images and un-ZIP it in the APP ?
This php zip image files
<?php
$dir = 'uploads/';
$zipFileName = 'comprimido.zip';
$zip = new ZipArchive();
if ($zip->open($zipFileName, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
$files = scandir($dir);
foreach ($files as $file) {
if ($file !== '.' && $file !== '..' && !is_dir($file)) {
$extension = pathinfo($file, PATHINFO_EXTENSION);
if (in_array($extension, array('jpg', 'jpeg', 'png', 'gif'))) {
$filePath = $dir . $file;
$zip->addFile($filePath, $file);
}
}
}
$zip->close();
echo "Compress";
} else {
echo "Error.";
}
?>