logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Download whole folder from Directoy?
Author
stu



Joined: 23 Nov 2005
Posts: 3
Location: Ontario, Canada

PostPosted: Wed 05 Apr '06 8:24    Post subject: Download whole folder from Directoy? Reply with quote

On my webserver I have a few pages that just show the Directory by using the standard Index Of blah blah. My question is, Is there a way to download a whole folder, rather then opening the folder and downloading each file in it seperately. Perhaps a zip on the fly feature of some sort? Im not to sure.

The server is running on Windows XP SP2, Apache/2.0.55 (Win32) PHP/5.1.2

Any suggestions as to how to do this would be appreciated, thanks,

-Stu
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Wed 05 Apr '06 8:47    Post subject: Reply with quote

If the folder content do not change to often you may create a zip file yourself. You can create tar.gz file on the fly with PHP=>PEAR=>TAR But that would take some time. I made some PHP editor myself. It can pack all files from a directority with subfolders. That takes a lot of CPU usage.

Be carefull with the script below. You need to know what you do.
if not download the hole editor. An english descrition is below the webpage.
Code:

$pack="C:/apache2/htdocs/downloads";
$format="gz";
$pack_name=$pack.".tar.gz"; //name of archives needs extension of the format

ini_set("max_execution_time",0);
      require_once "tar.php";
      $tar=new Archive_Tar($pack_name,$format);
      $tar->setErrorHandling(PEAR_ERROR_PRINT); //error_handler

      if(is_readable($verz)){
         $inhalt=opendir($verz);
         while($datei = readdir ($inhalt)){
              if($datei!="."&&$datei!=".."){
                   $files[] = $datei;
              };
         };
         closedir($inhalt);
         foreach ($files as $value)
                      {
                      echo $_lang['packed'].$value."<br />\n";
            $tar->add($verz."/".$value);
            }
         //bug with pack name under Windows for Download
         $this_dir=substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],"/")+1);
         $cut=$_SERVER['DOCUMENT_ROOT'];
         $package=str_replace("$cut","",$pack_name);
         //$package=str_replace("\\","/",$dir);

         echo "<br /><a href=\"$package\" target=\"_blank\">Download</a>";
         
      clearstatcache();
      }
      else
      {
         echo "That is no folder!";
      }

Back to top
stu



Joined: 23 Nov 2005
Posts: 3
Location: Ontario, Canada

PostPosted: Wed 05 Apr '06 23:12    Post subject: Reply with quote

Thanks, I will probably give this a try soon. Is this the only known way to download a whole folder? I would prefer something else, as my server is running off the computer I use every day, and high CPU usage isnt exactly something to look forward to. Thanks for the quick reply though James, and any other help would be useful, thanks,

-Stu
Back to top


Reply to topic   Topic: Download whole folder from Directoy? View previous topic :: View next topic
Post new topic   Forum Index -> Apache