Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Ordner kopieren samt Inhallt

Empfohlene Antworten

Veröffentlicht

Hi ich hab ne Frage, kann ich mit einem PHP Befehl einen Ordner mit Inhalt kopieren?!?!?!?

Danke McMaiers


This function copy one directory into another. There is no permissions checking
and no
error handling so watch out.

It was tested on Apache 1.3.27 with PHP 4.2.3 and IIS 5.0 with 4.0.5.

This code was not optimized.

===== SOURCE =====

<?php
// Path to this file by server directory structure.
$cfg_['localftpdir'] = join('/',array_splice(split("/",ereg_replace('\\\\',
'/', $PATH_TRANSLATED)), 0, count(split('/',ereg_replace('\\\\', '/',
$PATH_TRANSLATED)))-1));

// REMEMBER - No end backslash.
$startDir = $cfg_['localftpdir'].'/dir1';
$startDir = str_replace('//','/',$startDir); // for win systems
$endDir = $cfg_['localftpdir'].'/dir2';
$endDir = str_replace('//','/',$endDir); // for win systems

// Make base directory in end directory.
$arrCD = explode('/',$startDir);
mkdir($endDir.$arrCD[count($arrCD)-1],0700);
$endDir = $endDir.$arrCD[count($arrCD)-1];

function paste($param) {
$workDir = $param[0]; // Assign values to variables.
$endDir = $param[1]; // It's only for our comfort.
$var = $param[2]; //
$end = $param[3]; //

if ($dir = opendir($workDir.$var)) { // Open work directory.
$dirCount = 0; // Assume - there is no other directory
in work directory.
while (($file = readdir($dir)) !== false) { // List all elements.
// If there is directory and it's not '.' and '..' that not exists in end
directory.
// Choose first meet directory, select name and create it in end directory.
if ((is_dir($workDir.$var.'/'.$file) && (($file != '.') && ($file != '..')))
&& is_dir($endDir.$var.'/'.$file) == false) {
$dirCount++; break; // Break while - work directory is not empty.
}
if (is_file($workDir.$var.'/'.$file) && is_file($endDir.$var.'/'.$file) ==
false) {
copy($workDir.$var.'/'.$file,$endDir.$var.'/'.$file);
}
}
if ($dirCount==0) { // If there was no other directories.
if ($var == '' || $var == '/') { $end=true; } // And if we are in start
directory this means we must finish copying.
else { // Else...
$var = str_replace('//','/',$var);
$arrVar = split('/',$var);
$arrVar = array_slice($arrVar, 0, count($arrVar)-1);
$var = join('/',$arrVar); // cut $var path one element from end.
}
}
else {
mkdir($endDir.$var.'/'.$file,0700); // Make chosen directory in end
directory.
if ($var=='') { $var = '/'.$var.$file; } // Increase $var path.
else { $var = '/'.$var.'/'.$file; }
$var = str_replace('//','/',$var);
}
} closedir($dir); // Close work dir.

$param[0] = $workDir; // Assign values to array, ...
$param[1] = $endDir; //
$param[2] = $var; //
$param[3] = $end; //

return $param; // return array as a function result.
}

if ($dir = opendir($startDir)) { // Copy all files from main copied directory
to end directory.
while (($file = readdir($dir)) !== false) {
if (is_file($startDir.'/'.$file) && is_file($endDir.'/'.$file) == false) {
copy($startDir.'/'.$file,$endDir.'/'.$file);
}
}
} closedir($dir);

// Assign starting values...
$end = false;
$param[0] = $startDir;
$param[1] = $endDir;
$param[2] = '';
$param[3] = $end;

// Copy directory.
while ($end !== true) {
$param = paste($param);
$workDir = $param[0];
$endDir = $param[1];
$var = $param[2];
$end = $param[3];
}

echo 'Done !';
?>
[/PHP]

google ist dein freund,....

:)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.