Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7722793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:16:40+00:00 2026-06-01T04:16:40+00:00

I tried to copy any dir from my server to client’s pc but i

  • 0

I tried to copy any dir from my server to client’s pc but i dont know how is possible :S… as example… I have domain.com/Info and I want to copy that folder Info with content so I copy Info and copy in other folder but in my server… but i don’t know, how copy in client’s pc, the sense of my idea is, that if any client want to use my web can to copy that folder in him desktop Any Idea?? my code for copy dir in my server is

function full_copy( $source, $target ) {
    if ( is_dir( $source ) ) {
        @mkdir( $target );
        $d = dir( $source );
        while ( FALSE !== ( $entry = $d->read() ) ) {
            if ( $entry == '.' || $entry == '..' ) {
                continue;
            }
            $Entry = $source . '/' . $entry; 
            if ( is_dir( $Entry ) ) {
                full_copy( $Entry, $target . '/' . $entry );
                continue;
            }
            copy( $Entry, $target . '/' . $entry );
        }

        $d->close();
    }else {
        copy( $source, $target );
    }
}
$s = '/Appserv/www/CpVela/Info';
$des = '/Info/';
full_copy($s,$des);

new EDIT

well I’m Trying to make and download .zip but file.zip that my code creates is empty and damaged :S

my code is this

include "libs/pclzip-2-8-2/pclzip.lib.php";
require("libs/zipfile.php");

/* creates a compressed zip file */
function create_zip($files = array(),$destination = '',$overwrite = false) {
  if(file_exists($destination) && !$overwrite) { return false; }
  $valid_files = array();
  if(is_array($files)) {
    foreach($files as $file) {
      if(file_exists($file)) {
        $valid_files[] = $file;
      }
    }
  }
  if(count($valid_files)) {
    $zip = new ZipArchive();
    if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
      return false;
    }
    foreach($valid_files as $file) {
      $zip->addFile($file,$file);
    }
    $zip->close();
    return file_exists($destination);
  }
  else
  {
    return false;
  }
}
$array = array();
function full_copy( $source, $target ) {

    if ( is_dir( $source ) ) {
        @mkdir( $target );
        //$archivo  = new zipfile();
         $archive = new PclZip('zipfile.zip');
        $d = dir( $source );
        while ( FALSE !== ( $entry = $d->read() ) ) {
            if ( $entry == '.' || $entry == '..' ) {
                continue;
            }
            $Entry = $source . '/' . $entry; 
            if ( is_dir( $Entry ) ) {
                full_copy( $Entry, $target . '/' . $entry );
                continue;
            }
            if(count($array) > 1 ){
                array_push($array, $Entry);
                }else{
                    $array[0] = $Entry;
                    }
        //  $archivo->add_file($Entry,$Entry);
             //$v_list = $archive->add($Entry, PCLZIP_OPT_REMOVE_PATH, 'dev');
            //copy( $Entry, $target . '/' . $entry );
        }

        $d->close();


    }else {
        copy( $source, $target );
    }
}

$s = '/Appserv/www/CpVela/Info';
$des = '/Appserv/www/CpVela/';
full_copy($s,$des);
create_zip($array,'zipfile.zip');
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=zipfile.zip");
echo $zipfile->file(); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:16:42+00:00Added an answer on June 1, 2026 at 4:16 am

    You can’t do this from a web browser. PHP runs on the server where the web page executes, and nowhere else.

    If you want to allow the client to do this, you’d need to use another tool, or another language. Or just make a zip file that he can download.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to copy this example from this Multiprocessing lecture by jesse noller (as
i have tried to copy euro symbol from Wikipedia...and echo it (in my parent
I tried to copy and paste a component from one data module into another
I would like to have more than one button. I tried to copy code
I have tried unsuccessfully to copy the pwd to pbcopy as follows pwd |
I tried to make an independent copy of an array but couldnt get one.
tried uncommenting pam_limits.so from the pam.d directory but no luck. Basic PAM seems to
I tried to copy a column from one table to another table (in two
I have the problem that when I try to copy some files from php
How can I create an empty file at the DOS/Windows command-line? I tried: copy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.