Jump to content

[SOLVED] how to copy a folder and change the name?


A2xA

Recommended Posts

Basically I've been overcomplicating things.  I've been trying to make a directory and a folder and files at the same time.  when I could've just copied the folder and renamed it.

 

I want the users to submit a form that copys a folder and changes the name to what the user submitted into the form.

 

Is this possible would I use makedir() or copy()?

 

Thanks all help is appreciated!

Okay, I've got a copy code, but it's giving me errors.  Someone please Help?  :-\

 

<?php

$dir = $_POST[dir];

mkdir("/home/wiicharg/public_html/hubchat/$dir", 0755);
chmod("/home/wiicharg/public_html/hubchat/$dir", 0777);  

$file = 'http://wiicharged.com/hubchat/hubex/shout.php';
$newfile = 'http://wiicharged.com/hubchat/$dir/shout.php';

if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
}

$file = 'http://wiicharged.com/hubchat/hubex/shout.swf';
$newfile = 'http://wiicharged.com/hubchat/$dir/shout.swf';

if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
}

$file = 'http://wiicharged.com/hubchat/hubex/shout.txt';
$newfile = 'http://wiicharged.com/hubchat/$dir/shout.txt';

if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
}


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.