Results 1 to 5 of 5

Thread: Download Folder with Images Inside

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question 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.

  2. #2
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    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.
    Chris

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question Re: Download Folder with Images Inside

    Thanks for the reply. Can you please tell / show how to do the same ? Thanks.

  4. #4
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    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($destinationZIPARCHIVE::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.
    Chris

  5. #5
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    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
  •  



Click Here to Expand Forum to Full Width