Prob copying from server to local computer

Hi

I have a php script that lists the contents of a folder on the server.
/northern/acme/.

The user can place a checkmark next to each file they want to copy
the file from the server location to the c:\ emp folder on their computer.

My scripts copies ok, but it copies the file to the same directory and calls it “c:\ emp\pic_01.jpg”

How do I fix this? Below is part of my code…

for ($iCount = 0; $iCount < $iFileCount; $iCount++)
{
$sSource = $sArray[$iCount];
$sDestination = “C:\\ emp\\” . $sSource;

copy ($sSource, $sDestination);
}

Try this:


<?php

//function to zip and force download the files using PHP
function zipFilesAndDownload($file_names, $archive_file_name, $file_path)
{
    //create the object
    $zip = new ZipArchive();
    
    //create the file and throw the error if unsuccessful
    if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE) !== TRUE)
    {
        exit("cannot open <$archive_file_name>\
");
    }
    
    //add each files of $file_name array to archive
    foreach ($file_names as $files)
    {
        $zip->addFile($file_path . $files, $files);
    }
    $zip->close();
    
    //then send the headers to foce download the zip file
    header("Content-type: application/zip");
    header("Content-Disposition: attachment; filename=$archive_file_name");
    header("Pragma: no-cache");
    header("Expires: 0");
    readfile("$archive_file_name");
    exit;
}

$file_names        = array(
    'x.txt',
    'y.txt'
);

$archive_file_name = 'zipped.zip';
$file_path         = dirname(__FILE__) . '/';

zipFilesAndDownload($file_names, $archive_file_name, $file_path);

It is not good to use zip for all files. Most users will feel it bad.