私のサーバーからクライアントのPCに任意のディレクトリをコピーしようとしましたが、どうすればよいかわかりません:S ... example ...私はdomain.com/Infoを持っていますそのフォルダをコピーするInfoをコピーしてInfoをコピーして、他のフォルダにコピーするのですが、私のサーバにコピーします...しかし、クライアントのPCにコピーする方法、私のアイデアのセンスは、ウェブは、彼のデスクトップにそのフォルダをコピーすることができます任意のアイデア?? SクライアントのPCにPhpでディレクトリをコピーする
:私のサーバーでのコピーディレクトリのための私のコードは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);
新しいEDIT
よく私が作ると.zipファイルダウンロードしようとしているが、私のコードが作成されますfile.zipが空と損傷しています
私のコードでは、Webブラウザからこの操作を行うことはできません。この
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();
あなたはこれを行うことはできません。phpはクライアントのファイルシステムにアクセスできません。必要なファイルをすべてmake tarまたはgzipでダウンロードしてください。 – Fivell
恐ろしい概念です。もしあなたのファイルシステムに劇的な変更を加えることができるウェブサイトがあるとしたら、 –
うーん、どうすればいい? –