|
-
Mar 30th, 2010, 03:48 AM
#1
Thread Starter
Hyperactive Member
Download Folder with Images Inside
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.
-
Mar 30th, 2010, 07:09 AM
#2
Re: Download Folder with Images Inside
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.
-
Mar 30th, 2010, 07:44 AM
#3
Thread Starter
Hyperactive Member
Re: Download Folder with Images Inside
Thanks for the reply. Can you please tell / show how to do the same ? Thanks.
-
Mar 30th, 2010, 07:56 AM
#4
Re: Download Folder with Images Inside
Here is an example I found after a quick search for 'php zip folder':
PHP 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;
}
Call it like
PHP Code:
Zip('/folder/to/compress/', './compressed.zip');
It uses the php Zip extension so you'll need that enabled for it to work.
-
Mar 30th, 2010, 08:20 AM
#5
Re: Download Folder with Images Inside
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|