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.

Verzeichnisse kopieren

Empfohlene Antworten

Veröffentlicht

Moin,

ich möchte einen Verzeichnissbaum mit unterschiedlichen Inhalten verschieben.

gibt es eine fertige Funktion oder ähnliches ???

Ich habe auch daran gedacht, es zu zippen und an dem neuen Ort auszupacken, läuft aber unter einem Windows-Server und soll unter PHP laufen ...

Danke

Gruß

JayDee

Aus den Kommentaren zur PHP-Funktion copy:

this function copyes a file or folder, it needs another function (ls_a):

this works perfect.


// cp function
function cp($wf, $wto) { // it moves $wf to $wto
mkdir($wto,0777);
$arr = ls_a($wf);
foreach ($arr as $fn) {
if ($fn) {
$fl="$wf/$fn";
$flto="$wto/$fn";
if (is_dir($fl)) {
cp($fl,$flto);
} else {
copy($fl,$flto);
}
}
}
}

// ls_a function
// This function lists a directory.
// AND is needed for the cp function.
function ls_a($wh) {
if ($handle = opendir($wh)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." ) {
if (!$files) {
$files = "$file";
} else {
$files = "$file\n$files";
}
}
closedir($handle);
}
$arr = explode("\n",$files);
return $arr;
}
}
[/PHP]

Gruß Tobi

das sieht ja soweit cool aus, ich werde es ausprobieren ....

Danke

ich schaff es leider nicht !!! :((

<?

// cp function

function cp($wf, $wto) { // it moves $wf to $wto

mkdir($wto,0777);

$arr = ls_a($wf);

foreach ($arr as $fn) {

if ($fn) {

$fl="$wf/$fn";

$flto="$wto/$fn";

if (is_dir($fl)) {

cp($fl,$flto);

} else {

copy($fl,$flto);

}

}

}

}

// ls_a function

// This function lists a directory.

// AND is needed for the cp function.

function ls_a($wh) {

if ($handle = opendir($wh)) {

while (false !== ($file = readdir($handle))) {

if ($file != "." && $file != ".." ) {

if (!$files) {

$files = "$file";

} else {

$files = "$file\n$files";

}

}

closedir($handle);

}

$arr = explode("\n",$files);

return $arr;

}

}

HIER mein Aufruf !!!

cp ("images","test");

?>

es wird folgende Fehlermelung ausgegeben:

Warning: readdir(): 1 is not a valid Directory resource in D:\geosnrw\admin\copy-folder.php on line 26

Original geschrieben von JayDeee

HIER mein Aufruf !!!

cp ("images","test");

und auch dein fehler.

du musst wenn sich das script im gleichen verzeichnis liegt wie dein zu kopierender ordner folgenderweise aufrufen

z.B.:


cp ("./images","./test");
[/PHP]

wenn das nicht der fall ist musst du den pfad zum ordner mit angeben

z.B.:

[PHP]
cp ("../../images","../test");

na klar !!!!

vielen Dank !!!

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.