I wish to download the folder full with images from the server and save it to some location of my PC by default. Please help by providing some coding. Thanks in advance.
Printable View
I wish to download the folder full with images from the server and save it to some location of my PC by default. Please help by providing some coding. Thanks in advance.
I suggest creating a PHP script that will zip/rar up the folder full of images into a single file, then you can download and extract.
Thanks for the reply. Can you please tell / show how to do the same ? Thanks.
Here is an example I found after a quick search for 'php zip folder':
Call it likePHP Code:function Zip($source, $destination)
{
if (extension_loaded('zip') === true)
{
if (file_exists($source) === true)
{
$zip = new ZipArchive();
if ($zip->open($destination, ZIPARCHIVE::CREATE) === true)
{
$source = realpath($source);
if (is_dir($source) === true)
{
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $file)
{
$file = realpath($file);
if (is_dir($file) === true)
{
$zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
}
else if (is_file($file) === true)
{
$zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
}
}
}
else if (is_file($source) === true)
{
$zip->addFromString(basename($source), file_get_contents($source));
}
}
return $zip->close();
}
}
return false;
}
It uses the php Zip extension so you'll need that enabled for it to work.PHP Code:Zip('/folder/to/compress/', './compressed.zip');
I got the impression from the original post that this may not be something on your own server (which means the above will not work). however, if it is, then good luck to you.